title: Solr Spell Check
body: <p>I am working with Solr Spell Check . Got it up and running . However for certain misspells it is not giving the expected result : </p>
  
  <p>Correct Word : Cancer </p>
  
  <p>Incorrect Spelling : Cacner ,cacnar , cancar ,cancre,cancere . </p>
  
  <p>I am not getting "cancer" as the suggestion for "cacnar" instead it shows "inner" which although sounds more like cacner is not the correct suggestion . And for cacnar again I am getting a suggestion as 'pulmonary'.</p>
  
  <p>Any way of configuring it to display cancer instead of the other results ?</p>
  
  <p>Alternatively is there any score for the suggestions that can be referred to before showing it to the user ?</p>
  
  <p>As per request here is the configuration :
  The field used for dictionary (in schema.xml): </p>
  
  <pre><code>&lt;copyField source="procname"  dest="dtextspell" /&gt;
   &lt;field name = "dtextspell" stored="false" type="text_small" multiValued="true" indexed="true"/&gt;
  </code></pre>
  
  <p>Definition of "text_small" (again in schema.xml) : </p>
  
  <pre><code>&lt;fieldType name="text_small" class="solr.TextField" positionIncrementGap="100" omitNorms="true"&gt;
        &lt;analyzer type="index"&gt;
                &lt;tokenizer class="solr.StandardTokenizerFactory"/&gt;
              &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
              &lt;filter class="solr.StandardFilterFactory"/&gt;
        &lt;/analyzer&gt;
       &lt;analyzer type ="query"&gt;
                &lt;tokenizer class="solr.StandardTokenizerFactory"/&gt;    
  
       &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
       &lt;filter class="solr.StandardFilterFactory"/&gt;
       &lt;/analyzer&gt;
  &lt;/fieldType&gt;
  </code></pre>
  
  <p>In solrconfig.xml : </p>
  
  <pre><code>&lt;searchComponent name="spellcheck" class="solr.SpellCheckComponent"&gt;
  
  &lt;str name="queryAnalyzerFieldType"&gt;text_small&lt;/str&gt;
  &lt;lst name="spellchecker"&gt;
    &lt;str name="name"&gt;default&lt;/str&gt;
     &lt;str name="classname"&gt;solr.IndexBasedSpellChecker&lt;/str&gt;
      &lt;str name="field"&gt;dtextspell&lt;/str&gt;
      &lt;float name="thresholdTokenFrequency"&gt;.0001&lt;/float&gt;
  
    &lt;str name="spellcheckIndexDir"&gt;./spellchecker&lt;/str&gt;
     &lt;str name="field"&gt;name&lt;/str&gt;
      &lt;str name="buildOnCommit"&gt;true&lt;/str&gt;
  
  &lt;/lst&gt;&lt;/searchComponent&gt;
  </code></pre>
  
  <p>Attached it to the select request handler like this : </p>
  
  <pre><code>&lt;requestHandler name="/select" class="solr.SearchHandler"&gt;
  
   &lt;lst name="defaults"&gt;
     &lt;str name="echoParams"&gt;explicit&lt;/str&gt;
  
     &lt;int name="rows"&gt;10&lt;/int&gt;
     &lt;str name="spellcheck.count"&gt;10&lt;/str&gt;
     &lt;str name="df"&gt;text&lt;/str&gt;
   &lt;/lst&gt;
   &lt;arr name="last-components"&gt;
     &lt;str&gt;spellcheck&lt;/str&gt;
   &lt;/arr&gt;   &lt;/requestHandler&gt;
  </code></pre>
  
  <p>To build the spell check : </p>
  
  <pre><code>http://localhost:8080/solr/select?q=*:*&amp;spellcheck=true&amp;spellcheck.build=true
  </code></pre>
  
  <p>To search for term : </p>
  
  <pre><code>http://localhost:8080/solr/select?q=procname:%22cacner%22&amp;spellcheck=true&amp;defType=edismax
  </code></pre>
  
  <p>The response XML : </p>
  
  <pre><code>&lt;lst name="spellcheck"&gt;&lt;lst name="suggestions"&gt;
       &lt;lst name="cacner"&gt;
       &lt;int name="numFound"&gt;1&lt;/int&gt;
       &lt;int name="startOffset"&gt;10&lt;/int&gt;
       &lt;int name="endOffset"&gt;16&lt;/int&gt;
        &lt;arr name="suggestion"&gt;
       &lt;str&gt;inner&lt;/str&gt; &lt;end tags start from here&gt;
  </code></pre>
  
  <p>Hope it helps !!</p>