Enable spellcheck and other handlers

Written by: Open Solr Administrator

The schema.xml file that is created once you create your opensolr collection, comes with a field type called "spell" and a field defined called "spell".
Simply make sure that you have those two defined in your custom schema.xml and you should have spellcheck and terms suggestion enabled.
The most important thing is to make sure that the spellcheck component is loaded in every Request Handler that you are using inside solrconfig.xml just as shown at #4.

So, just make sure the following snippets are present in your schema.xml file:

1) The spell field type definition:

<fieldtype class="solr.TextField" name="spell" positionincrementgap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory">
    <filter class="solr.StopFilterFactory" ignorecase="true" words="stopwords.txt">
    <filter class="solr.StandardFilterFactory">
    <filter class="solr.RemoveDuplicatesTokenFilterFactory">
  </filter></filter></filter></tokenizer></analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory">
    <filter class="solr.SynonymFilterFactory" expand="true" 
        ignorecase="true" synonyms="synonyms.txt">
    <filter class="solr.StopFilterFactory" ignorecase="true" words="stopwords.txt">
    <filter class="solr.StandardFilterFactory">
    <filter class="solr.RemoveDuplicatesTokenFilterFactory">
  </filter>
</filter></filter></filter></tokenizer></analyzer>
</fieldtype>

2) The spell field definition:

<field name="spell" type="spell" indexed="true" stored="false" multiValued="true" />

3) Populate the spell dictionary (field) with values from your content field(s):

<copyField source="content" dest="spell" />
<copyField source="description" dest="spell" />
 

4) Make sure in solrconfig.xml you have something like this:

<requestHandler name="/select" class="solr.SearchHandler" default="true">
     <lst name="defaults">
       <str name="echoParams">explicit</str>
       <int name="rows">50</int>
     </lst>
     <arr name="last-components">
       <str>spellcheck</str>
     </arr>
</requestHandler>