簡體   English   中英

找不到Elasticsearch NEST建議者解析器

[英]Elasticsearch NEST Suggester parser(s) not found

我正在嘗試利用Elasticsearch的“ Asker ”功能。

使用短語,術語或完成,我總是得到以下錯誤變化。

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 在這里回答了我的問題

我有一個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);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM