Apache solr 布尔搜索 100% 匹配



>我的 apache solr 中有 2 个文档,具有以下字段值

custom_value: haris mehmood
custom_value: hari mehmood

我正在尝试进行布尔搜索并使用dismax,我的查询+haris,我执行以下操作:

defType=dismax & mm=100% & ps=0 & q=+haris & wt=json

PS:我自己在查询字符串中添加了空格,以便更好地理解

我只想要 1 个结果作为响应,应该是第一个,即haris mehmood而不是有hari mehmood的那个

我想知道我做错了什么,如果没有,有没有办法实现我想要的。

如果你想处理该查询/字段中的非英语文本,那么使用不同的分析,而不是做任何英语语言的事情。

text_en可能会进行一些词干提取,并且"haris"中的 s 正在被删除,因此它与您的查询匹配。

您正在使用字段类型text_en。它有一个过滤器Porter Stem Filter,可以词干并删除尾随s

创建一个不带Porter Stem Filter的新字段类型

<fieldType name="text_simple" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<!-- Case insensitive stop word removal.
-->
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
</analyzer>
</fieldType>

并将字段类型更改为text_simple并重新加载核心并重新索引数据

最新更新