如何在 solr 中搜索准确的短语。假设,当我搜索“How_to_Search_this”时,它应该给我
1.“how_to_search_this”(不区分大小写)
2.“How_to_search_this”的结果
但不是像
1.“How_to_search_this_thing”
2.“How_to_search_that_thing ”这样的结果
请帮忙。谢谢!
只获得精确的小写命中,使用 KeywordTokenizer。KeywordTokenizer 将输入字符串保留为单个标记,但同时string
也KeywordTokenizer
允许您附加过滤器。
<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
这只会在查询值与索引值相同时为您提供命中,大小写除外。