Search code examples
solrspell-checking

Solr spell check mutliwords


Could not figure out actual reason why my configured Solr spell checker not giving desire output. In my indexed data query: symphony+mobile has around 3.5K+ docs and spell checker detect it as correctly spelled. When i miss-spell "symphony" in query: symphony+mobile it showing only results for "mobile" and spell checker detect this query as correctly spelled. I have searched this query in different combination. Please find search result stat

Query: symphony

**ResultFound**: 1190
**SpellChecker**: correctly spelled

Query: mobile

**ResultFound**: 2850
**SpellChecker**: correctly spelled

Query: simphony

**ResultFound**: 0
**SpellChecker**: symphony 
**Collation Hits**: 1190

Query: symphony+mobile

**ResultFound**: 3585
**SpellChecker**: correctly spelled 

Query: simphony+mobile

**ResultFound**: 2850
**SpellChecker**: correctly spelled

Query: symphony+mbile

**ResultFound**: 1190
**SpellChecker**: correctly spelled 

In last two queries it should suggest something for miss-spelled word "simphony" and "mbile"

Please find my configuration below. Only spell check configuration are shown.

solrconfig.xml:

  <requestHandler name="/select" class="solr.SearchHandler">
      <lst name="defaults">

        <str name="echoParams">explicit</str>
        <int name="rows">10</int>
        <str name="df">product_name</str>

        <str name="spellcheck">on</str>
        <str name="spellcheck.dictionary">default</str>
        <str name="spellcheck.dictionary">wordbreak</str>
        <str name="spellcheck.extendedResults">true</str>
        <str name="spellcheck.count">5</str>
        <str name="spellcheck.alternativeTermCount">2</str>
        <str name="spellcheck.maxResultsForSuggest">5</str>
        <str name="spellcheck.collate">true</str>
        <str name="spellcheck.collateExtendedResults">true</str>
        <str name="spellcheck.maxCollationTries">5</str>
        <str name="spellcheck.maxCollations">3</str>

      </lst>
      <arr name="last-components">
        <str>spellcheck</str>
      </arr>
  </requestHandler>

  <searchComponent name="spellcheck" class="solr.SpellCheckComponent">

      <str name="queryAnalyzerFieldType">text_suggest</str>

      <lst name="spellchecker">
        <str name="name">default</str>
        <str name="field">suggest</str>
        <str name="classname">solr.DirectSolrSpellChecker</str>
        <str name="distanceMeasure">internal</str>
        <float name="accuracy">0.5</float>
      </lst>

      <lst name="spellchecker">
        <str name="name">wordbreak</str>
        <str name="field">suggest</str>
        <str name="classname">solr.WordBreakSolrSpellChecker</str>
        <str name="combineWords">true</str>
        <str name="breakWords">true</str>
        <int name="maxChanges">10</int>
        <int name="minBreakLength">5</int>
      </lst>

  </searchComponent>

schema.xml:

  <fieldType name="text_suggest" class="solr.TextField" positionIncrementGap="100">
          <analyzer>
            <tokenizer class="solr.UAX29URLEmailTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true"
                    words="stopwords.txt"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.ASCIIFoldingFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
          </analyzer>
  </fieldType>

Solution

  • SOLVED :) Found actual reason of my problem. I set "maxResultsForSuggest" to 5 thats why it's not showing suggestion because each word in query has more search results than 5