Search code examples
solrsolrjstemming

How to configure SOLR for stemming


I am learning solr and using solr-5.3.0. I want to include common stemmers in solr. I followed this Tutorial. But after making changes to the schema.xml when I search for a term I didn't get desired output. ALso, there are many schema.xml and I am not sure which one to edit.

{
"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
        }
    ]
  }
}

when I search for holidays it didn't give any result. I added this in 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>

Solution

  • try with below 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>