如何在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_keyword
和analyzer_term
用于文档的字段。 因为您的代码现在只指定了一些自定义分析器,所以没有在任何地方使用。
看看specifying an index time analyzer:
At index time, if no
analyzer
has been specified, it looks for an analyzer in the index settings calleddefault
. Failing that, it defaults to using thestandard
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/