One word phrase search to avoid stemming in Solr

扶醉桌前 提交于 2019-12-05 02:06:31

问题


I have stemming enabled in my Solr instance, I had assumed that in order to perform an exact word search without disabling stemming, it would be as simple as putting the word into quotes. This however does not appear to be the case?

Is there a simple way to achieve this?


回答1:


There is a simple way, if what you're referring to is the "slop" (required similarity) as part of a fuzzy search (see the Lucene Query Syntax here).

For example, if I perform this search:

 q=field_name:determine

I see results that contain "determine", "determining", "determined", etc.. If I then modify the query like so:

 q=field_name:determine~1

I only see results that contain the word "determine". This is because I'm specifying a required similarity of 1, which means "exact match". I can specify this value anywhere from 0 to 1.




回答2:


Another thing you can do is index the same text without stemming in one field, and with stemming in another. Boost the non-stemmed field & that should prefer exact versions of words to stemmed versions. Of course you could also write your own query parser that directs quoted phrases to the non-stemmed field only.



来源:https://stackoverflow.com/questions/6215389/one-word-phrase-search-to-avoid-stemming-in-solr

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