solr : how to match singular and plural words

I have the below words in the document 1) Sweetings 2) Masters

Configuration for text_general

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <!-- in this example, we will only use synonyms at query time
    <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
    <filter class="solr.LowerCaseFilterFactory"/>

  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.LowerCaseFilterFactory"/>


How do I make sure if user searches for 1) master it matches masters 2) masters it matches masters 3) sweetings it matches sweetings

I used snowballporter and it didn't work.


The field type text_general, as you can see from your quote, does not include the <filter class="solr.PorterStemFilterFactory"/>. The field typetext_en however does, change your field type to it and re-index your data to get the desired results.

If you are asking why and how any other queries or text content will be analyzed in Solr, I recommend the Analysis Screen from the Solr Admin gui.

You can go there, type in "masters" and for the field type, select text_en or text_general. You will see that for text_en and the input "masters", the token "master" is not matched, only "masters". However, analyzing with the text_general field and the input "masters", both "masters" and "master" are matched.

One problem with the SnowballPorterFilterFactory is it changes the words not just adds to them...

This is from the synonyms.txt file... wedding, married, couple, espouse, marriage, unite, alliance, amalgamation, association, confederation, conjugality, connubiality, consortium, coupling, espousal, matrimony, mating, matrimony, merger, monogamy, nuptials, pledging, sacrament, spousal, wedded, weddings, ceremony, wedlock, bridal

SnowballPorterFilterFactory changes them to this... (description:wed | description:marri | description:coupl | description:espous | description:marriag | description:unit | description:allianc | description:amalgam | description:associ | description:confeder | description:conjug | description:connubi | description:consortium | description:coupl | description:espous | description:matrimoni | description:mate | description:merger | description:monogami | description:nuptial | description:pledg | description:sacrament | description:spousal | description:wed | description:wed | description:ceremoni | description:wedlock | description:bridal)

This filter will remove the plural versions...

That will only remove plural words and not truncate the words.

This filter will remove possessives (trailing 's) plural terms.

Need Your Help

Override Topmenu.php in magento

magento overriding

I'm trying to override the _getHtml function in Mage_Page_Block_Html_Topmenu magento class