You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Shivanand Yeurkar <sh...@gmail.com> on 2014/12/13 04:34:49 UTC

Spellcheck not working for alphanumeric words

Hi,

Spell check is not working for alphanumeric and numeric words.
  For example, I have indexed alphanumeric words like
BL5C
BL4C
BL5F
Spellcheck for word "BL" does not suggest me any of above results.

I have same problem even with numeric words
For example, indexed words-
Nokia Lumia 520
Nokia Lumia 625
Nokia Lumia 925
 Spellcheck for word "Nokia Lumia 5" does not suggest me "Nokia Lumia 520"

How to make spell check work for numeric fields in Solr?

I am using Solr 4.7.0. Following is spellcheck component configuration
SolrConfig.xml
----------------------
  <searchComponent name="spellcheck" class="solr.SpellCheckComponent">

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

    <!-- Multiple "Spell Checkers" can be declared and used by this
         component
      -->

    <!-- a spellchecker built from a field of the main index -->
    <lst name="spellchecker">
      <str name="name">default</str>
      <str name="field">ecomm_dictionary</str>
      <str name="classname">solr.DirectSolrSpellChecker</str>
  <str name="distanceMeasure">internal</str>
      <!-- the spellcheck distance measure used, the default is the
internal levenshtein -->

      <!-- minimum accuracy needed to be considered a valid spellcheck
suggestion -->
      <!--<str name="accuracy">0.4</str>-->
      <!-- the maximum #edits we consider when enumerating terms: can be 1
or 2 -->

      <!-- uncomment this to require suggestions to occur in 1% of the
documents-->
      <!--<float name="thresholdTokenFrequency">.001</float>-->
     <str name="buildOnCommit">true</str>

 <int name="maxEdits">2</int>
     <int name="minPrefix">0</int>
     <int name="maxInspections">20</int>
     <int name="minQueryLength">2</int>
     <float name="maxQueryFrequency">0.001</float>

    </lst>

    <!-- a spellchecker that can break or combine words.  See "/spell"
handler below for usage -->
    <lst name="spellchecker">
      <str name="name">wordbreak</str>
      <str name="classname">solr.WordBreakSolrSpellChecker</str>
      <str name="field">ecomm_dictionary</str>
      <str name="combineWords">true</str>
  <int name="minBreakLength">2</int>
      <str name="breakWords">true</str>
      <int name="maxChanges">10</int>
  <str name="buildOnCommit">true</str>
    </lst>
  </searchComponent>


 Schema.xml
 ---------------

   <fieldType name="text_dictionary" class="solr.TextField"
positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" enablePositionIncrements="true" />
        <filter class="solr.LowerCaseFilterFactory"/>
   </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" enablePositionIncrements="true" />
        <filter class="solr.LowerCaseFilterFactory"/>
<!--<filter class="solr.WordDelimiterFilterFactory"
preserveOriginal="1"/>-->
<!--<filter class="solr.SynonymFilterFactory"
synonyms="category-synonyms.txt" ignoreCase="true" expand="true"/>-->
      </analyzer>
    </fieldType>
 <field name="ecomm_dictionary" type="text_dictionary" stored="true"
indexed="true" multiValued="true"/>


Regards,
Shivanand