gpt4 book ai didi

c# - Elasticsearch NEST创建不区分大小写的索引

转载 作者:行者123 更新时间:2023-12-03 01:39:43 25 4
gpt4 key购买 nike

如何在NEST中创建将不区分大小写与TermQuery进行比较的索引?

我尝试了以下方法(以及许多类似方法),但是我的TermQuery只返回区分大小写的匹配结果。

Client.CreateIndex("my_index", (c) => c
.Settings(s => s
.Analysis(an => an
.Analyzers(ans => ans
.Custom("analyzer_keyword", cu => cu
.Tokenizer("keyword")
.Filters("lowercase")
)
.Custom("analyzer_term", cu => cu
.Tokenizer("term")
.Filters("lowercase")
)
)
)
)
);

最佳答案

我不知道如何使用NEST进行此操作,但我知道一件事-您有两种选择:

  • 您可以指定default分析器

  • 要么
  • ,您需要,将analyzer_keywordanalyzer_term用于文档的字段。

  • 因为您的代码现在只指定了一些自定义分析器,所以没有在任何地方使用。
    看看specifying an index time analyzer:

    At index time, if no analyzer has been specified, it looks for an analyzer in the index settings called default. Failing that, it defaults to using the standard analyzer.


    specifying a search time analyzer:

    The analyzer to use to search a particular field is determined by looking for:

    • An analyzer specified in the query itself.
    • The search_analyzer mapping parameter.
    • The analyzer mapping parameter.
    • An analyzer in the index settings called default_search.
    • An analyzer in the index settings called default.
    • The standard analyzer.

    关于c# - Elasticsearch NEST创建不区分大小写的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48788329/

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