Can I protect short words from an n-gram filter in Solr?

霸气de小男生 提交于 2020-01-02 05:59:14

问题


I have seen this question about searching for short words in Solr. I am wondering if there is another possible solution to a similar problem. I am using the EdgeNGramFilter with a minGramSize of 3. I want to protect a specific set of shorter words (two-letter acronyms, mainly) from being ignored, but I'd like to keep that minGramSize of 3 for everything else. EdgeNGramFilter doesn't support a protected words list. Is there any filter or setting that makes this possible within a single field type, or will I need to write one?

Or, am I thinking about this the wrong way?


回答1:


Thought hard about this one, but the answer in the other question you mention seems to be the only way. This will be a useful feature for the EdgeNGramFilter though.

For now, you can keep a copy field and a KeepWordFilterFactory for it with only the acronyms you need. Or if your list of acronyms is not know a priori, use a LengthFilter.



来源:https://stackoverflow.com/questions/15004758/can-i-protect-short-words-from-an-n-gram-filter-in-solr

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