gpt4 book ai didi

c# - 找不到Elasticsearch NEST建议者解析器

转载 作者:行者123 更新时间:2023-12-02 23:53:23 25 4
gpt4 key购买 nike

我正在尝试利用Elasticsearch的'Suggester'功能。

使用短语,术语或完成,我总是得到以下错误变化。

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))));

希望它能奏效让我知道您是否仍然遇到任何问题。

关于c# - 找不到Elasticsearch NEST建议者解析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56007354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com