如果文档中使用复数,而搜索文本中使用单数,则配置SOLR查找文档? [英] Configure SOLR to find documents if the plural is used in the document, and the singular in the search text?
问题描述
我用的是solr,设置在localhost:8983我基本上使用的是开箱即用的示例.我输入了一个名为Car"的文档,另一个名为Cars".
I am using solr, set up at localhost:8983 I am basically using the out of the box example. I have entered one document with a name "Car", and another with a name "Cars".
如果我访问任何一个:
http://localhost:8983/solr/select?q=Car
或
http://localhost:8983/solr/select?q=Cars
我希望得到这两个文件.目前,我没有.
I would expect to get both documents. At the moment, I don't.
在schema.xml"的fields标签中,name"的条目是:
In the fields tag of "schema.xml", the entry for "name" is:
text_general"具有以下分析器"(不含词干分析器):
"text_general" has the following "analyzers" (without the stemmers):
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
我尝试为每个分析器添加一个词干分析器.我试过了:
I tried to add a stemmer to each analyzer. I tried:
<filter class="solr.PorterStemFilterFactory"/>
<filter class="solr.KStemFilterFactory"/>
<filter class="solr.EnglishMinimalStemFilterFactory"/>
这样做会使搜索汽车"会找到汽车",但我永远找不到汽车".
Doing so makes it such that searching for "Cars" will find "Car", but I can never find "Cars".
应该可以找到汽车"吗?
Should it be possible to find "Cars"?
任何帮助将不胜感激.谢谢.
Any help would be greatly appreciated. Thank you.
推荐答案
是可以的,只需要在最后(LowerCaseFilterFactory 之后)添加 porter 过滤器:
It is possible, just add porter filter at the end (after LowerCaseFilterFactory):
<filter class="solr.SnowballPorterFilterFactory" language="English" />
阅读更多:
如果没有特殊需要,我不会将分析器分为索引和查询时间.您的查询时间分析器看起来非常适合在这两种情况下使用它.
If there is no special need, I would not divide analyser to index and query time. Your query time analyser looks perfectly good to use it in both cases.
这篇关于如果文档中使用复数,而搜索文本中使用单数,则配置SOLR查找文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!