Exact word search in Solr

混江龙づ霸主 提交于 2019-12-05 07:47:46

问题


I have a question which closely relates to this question.

In my schema I have a field

<field name="text" type="textgen" indexed="true" stored="true" required="true"/>

This gives an exact match, ie. stemming disabled

eat = eat

Is it possible, while configured to textgen to search for other variants of the word

eg. eat = eat, eats, eating

eat~0 will give similar sounding words such as meat, beat etc. but this is not what I want.

I'm starting to think that the only way to achieve this is to add another field with something other then textgen but if there is a simpler way I am very interested to hear it.


回答1:


Using copyfield statements is the normal approach in Solr. Since stemming is the answer to exactly what you're asking, this is what I recommend you to use. You can set stored=false if you are worried about index size.

You might also use lemmatisation, which is the opposite of stemming - where you instead add a words all inflected forms. This is typically performed on the search query, expanding e.g., eat to eat, eats, eating etc.

The third alternative might be to use wildcard search, although I wouldn't encourage it. Not least since it bypasses all schema configured filters for the target field.




回答2:


If you use text as the field type, then eat, eats, eaten and eating will all be stored as eat and a search for FieldName:eat will find all of them. If you change the field type to text-gen then the search for FieldName:eat will only find "eat", not eats, eaten or eating.



来源:https://stackoverflow.com/questions/6428597/exact-word-search-in-solr

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