如果在文档中使用复数形式,则配置SOLR以查找文档,在搜索文本中使用单数形式?

时间:2012-01-31 19:15:28

标签: solr

我正在使用solr,在localhost:8983处设置 我基本上使用开箱即用的例子。 我输入了一个名为“Car”的文档,另一个名为“Cars”的文档。

如果我访问其中一个:

http://localhost:8983/solr/select?q=Car

http://localhost:8983/solr/select?q=Cars

我希望得到这两份文件。目前,我没有。

在“schema.xml”的fields标记中,“name”的条目是:

“text_general”具有以下“分析器”(没有词干分析器):

<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>

我试图为每个分析仪添加一个词干分析器。我试过了:

<filter class="solr.PorterStemFilterFactory"/>
<filter class="solr.KStemFilterFactory"/>
<filter class="solr.EnglishMinimalStemFilterFactory"/>

这样做是为了搜索“汽车”会找到“汽车”,但我永远找不到“汽车”。

是否可以找到“汽车”?

非常感谢任何帮助。谢谢。

2 个答案:

答案 0 :(得分:19)

有可能,只需在末尾添加porter过滤器(在LowerCaseFilterFactory之后):

<filter class="solr.SnowballPorterFilterFactory" language="English" />

了解更多:

  1. Snowball docs with example of use in analyser
  2. Solr LanguageAnalysis
  3. The English (Porter2) stemming algorithm
  4. 如果没有特殊需要,我不会将分析器划分为索引和查询时间。您的查询时间分析器看起来非常适合在两种情况下使用它。

答案 1 :(得分:1)

我发现在shema.xml字段中从text_general更改为text_en可以解决这个问题