如何配置SOLR用于词干

时间:2015-09-01 13:47:03

标签: solr solrj stemming

我正在学习solr并使用solr-5.3.0。我想在solr中包含常见的词干分析器。我跟着这个Tutorial。但是当我搜索一个术语后对schema.xml进行更改后,我没有获得所需的输出。此外,还有很多schema.xml,我不确定要编辑哪一个。

{
"responseHeader": {
    "status": 0,
    "QTime": 1,
    "params": {
        "indent": "true",
        "q": "HOLIDAY",
        "_": "1441115332479",
        "wt": "json"
    }
},
"response": {
    "numFound": 2,
    "start": 0,
    "docs": [
        {
            "id": "1234",
            "name": [
                "A lovely winter holiday"
            ],
            "_version_": 1511117845476409300
        },
        {
            "id": "1235",
            "name": [
                "A lovely summer holiday"
            ],
            "_version_": 1511118023312801800
        }
    ]
  }
}

当我搜索holidays时,它没有给出任何结果。我在schema.xml中添加了此内容。

<fieldType name="text" class="solr.TextField" omitNorms="false">
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" tokenizerFactory="solr.StandardTokenizerFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
</fieldType>

1 个答案:

答案 0 :(得分:0)

尝试使用以下fieldType ....

<fieldType name="text" class="solr.TextField" omitNorms="false">
    <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
    <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" tokenizerFactory="solr.StandardTokenizerFactory"/>
    </analyzer>
    </fieldType>