Solr: Multi-word synonyms

∥☆過路亽.° 提交于 2019-12-03 20:28:42

Based on this link you should search for "black berry" with quotes as using it without quotes causes an OR query i.e. black OR berry

In Solr-6.5.0 you can enables query-time multi-term synonyms by setting below parameter

From Documentation

The sow Parameter

Split on whitespace: if set to false, whitespace-separated term sequences will be provided to text analysis in one shot, enabling proper function of analysis filters that operate over term sequences, e.g. multi-word synonyms and shingles. Defaults to true: text analysis is invoked separately for each individual whitespace-separated term.

[synonym.txt]

black berry => blackberry

[Example]

q=black berry
&sow=false
&debug=query

[Debug-Response]

<lst name="debug">
<str name="rawquerystring">black berry</str>
<str name="querystring">black berry</str>
<str name="parsedquery">_text_:blackberry</str>
<str name="parsedquery_toString">_text_:blackberry</str>
<str name="QParser">LuceneQParser</str>
</lst>

Now you can see from debug response that I have searched for black berry, but synonym filter factory maps to the word that I have mentioned in synonym.txt.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!