找不到 Elasticsearch NEST Suggester 解析器
Elasticsearch NEST Suggester parser(s) not found
我正在尝试使用 Elasticsearch 的“Suggester”功能。
使用 Phrase、Term 或 Completion 我总是得到以下错误变化。
unable to parse SuggestionBuilder with name [COMPLETION]: parser not found"
unable to parse SuggestionBuilder with name [TERM]: parser not found"
unable to parse SuggestionBuilder with name [PHRASE]: parser not found"
我尝试了多个 6.x NEST 版本,它们都有相同的问题。
升级到 7.0alpha1 确实改变了错误,但似乎会导致无数其他问题,我宁愿不在生产中使用 alpha 库。
我目前正在学习本教程并将其应用到我现有的代码中:https://github.com/elastic/elasticsearch-net-example/tree/6.x-codecomplete-netcore#part-6-suggestions
目前正在使用 NEST 6.1
型号:
public class SearchResult {
public SearchResult()
{
TitleSuggest = new CompletionField {Input = new List<string>(Title.Split(' '))};
}
public CompletionField TitleSuggest { get; set; }
//etc
}
索引方法:
public async Task<IActionResult> CreateIndex()
{
await _searchClient.CreateIndexAsync(SearchIndexName, indexSelector =>
indexSelector
.Mappings(mappingsDescriptor =>
mappingsDescriptor.Map<Models.SearchResult>(y => y.AutoMap().Properties(pr=>pr.Completion(c => c.Name(p => p.TitleSuggest)
))))
建议方法:
public async Task<ISearchResponse<SearchResult>> Suggest(string keyword)
{
return await _searchClient.SearchAsync<SearchResult>(
s =>
s.Suggest(ss => ss
.Completion("title", cs => cs
.Field(f => f.TitleSuggest)
.Prefix(keyword)
.Fuzzy(f => f
.Fuzziness(Fuzziness.Auto)
)
.Size(5))
}
我很难破译错误。
似乎 NEST 库缺少 Suggester 解析器?
任何帮助都会很棒,谢谢!
试试这个:
var searchResponse = await _searchClient.SearchAsync<SearchResult>(s => s
.Index(ConfigurationManager.AppSettings.Get("index"))
.Type(ConfigurationManager.AppSettings.Get("indextype"))
.Suggest(su => su
.Completion("suggest", cs => cs
.Size(20)
.Field(f => f.TitleSuggest)
.Fuzzy(f => f
.Fuzziness(Fuzziness.Auto))
.Size(5))));
作为跟进,@RussCam 回答了我的问题 here
我有一个 ConnectionSetting (DefaultFieldNameInferrer) 是大写我的建议者
private IElasticClient ElasticClient(IConfiguration _config, string defaultIndex)
{
var settings = new ConnectionSettings(new Uri(_config.GetSection("Search:Url").Value))
.BasicAuthentication(_config.GetSection("Search:User").Value, _config.GetSection("Search:Password").Value)
.DefaultIndex(_config.GetSection(defaultIndex).Value);
//settings.DefaultFieldNameInferrer(p => p.ToUpper(CultureInfo.CurrentCulture));
//Enable ElasticSearch Debugging
settings.PrettyJson().DisableDirectStreaming();
return new ElasticClient(settings);
}
我正在尝试使用 Elasticsearch 的“Suggester”功能。
使用 Phrase、Term 或 Completion 我总是得到以下错误变化。
unable to parse SuggestionBuilder with name [COMPLETION]: parser not found"
unable to parse SuggestionBuilder with name [TERM]: parser not found"
unable to parse SuggestionBuilder with name [PHRASE]: parser not found"
我尝试了多个 6.x NEST 版本,它们都有相同的问题。 升级到 7.0alpha1 确实改变了错误,但似乎会导致无数其他问题,我宁愿不在生产中使用 alpha 库。
我目前正在学习本教程并将其应用到我现有的代码中:https://github.com/elastic/elasticsearch-net-example/tree/6.x-codecomplete-netcore#part-6-suggestions
目前正在使用 NEST 6.1
型号:
public class SearchResult {
public SearchResult()
{
TitleSuggest = new CompletionField {Input = new List<string>(Title.Split(' '))};
}
public CompletionField TitleSuggest { get; set; }
//etc
}
索引方法:
public async Task<IActionResult> CreateIndex()
{
await _searchClient.CreateIndexAsync(SearchIndexName, indexSelector =>
indexSelector
.Mappings(mappingsDescriptor =>
mappingsDescriptor.Map<Models.SearchResult>(y => y.AutoMap().Properties(pr=>pr.Completion(c => c.Name(p => p.TitleSuggest)
))))
建议方法:
public async Task<ISearchResponse<SearchResult>> Suggest(string keyword)
{
return await _searchClient.SearchAsync<SearchResult>(
s =>
s.Suggest(ss => ss
.Completion("title", cs => cs
.Field(f => f.TitleSuggest)
.Prefix(keyword)
.Fuzzy(f => f
.Fuzziness(Fuzziness.Auto)
)
.Size(5))
}
我很难破译错误。 似乎 NEST 库缺少 Suggester 解析器? 任何帮助都会很棒,谢谢!
试试这个:
var searchResponse = await _searchClient.SearchAsync<SearchResult>(s => s
.Index(ConfigurationManager.AppSettings.Get("index"))
.Type(ConfigurationManager.AppSettings.Get("indextype"))
.Suggest(su => su
.Completion("suggest", cs => cs
.Size(20)
.Field(f => f.TitleSuggest)
.Fuzzy(f => f
.Fuzziness(Fuzziness.Auto))
.Size(5))));
作为跟进,@RussCam 回答了我的问题 here
我有一个 ConnectionSetting (DefaultFieldNameInferrer) 是大写我的建议者
private IElasticClient ElasticClient(IConfiguration _config, string defaultIndex)
{
var settings = new ConnectionSettings(new Uri(_config.GetSection("Search:Url").Value))
.BasicAuthentication(_config.GetSection("Search:User").Value, _config.GetSection("Search:Password").Value)
.DefaultIndex(_config.GetSection(defaultIndex).Value);
//settings.DefaultFieldNameInferrer(p => p.ToUpper(CultureInfo.CurrentCulture));
//Enable ElasticSearch Debugging
settings.PrettyJson().DisableDirectStreaming();
return new ElasticClient(settings);
}