Shrinath
Shrinath

Reputation: 8118

How to make Solr's spell checker ignore case?

How do you ask the example spellchecker to ignore case ? I am using all defaults shown in the demo.
Now I see that if I type Ancient, it asks "did you mean ancient ? " What do I do ?

ps : I don't have anything that has the word "spell" in my schema.xml!!!! How is it working ?

Upvotes: 2

Views: 3660

Answers (2)

Nick Clark
Nick Clark

Reputation: 4467

The schema should have a field type called "spell" that is used for spell checking. This will lowercase all words used by the spellchecker so you don't have to worry about case. Here is an example of how to use this field type.

Create a field in your schema for spell checking.

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

And then use a copy field to copy data into this field. The example, the code below will copy the "product_name" field into the spell checker.

<copyField source="product_name" dest="spelling"/>

Edit...

Sorry... I though the "spell" field type was in the default schema. Add this to your schema in the same section as the other fieldType tags.

<fieldType name="spell" class="solr.TextField" 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.LowerCaseFilterFactory" />
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" 
        ignoreCase="true" expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" 
        words="stopwords.txt"/>
    <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
</fieldType>

Upvotes: 9

nikhil500
nikhil500

Reputation: 3450

Please post your solrconfig.xml - I think that will provide a clue.

My best guess will be that solrconfig.xml contains the config for the spellchecker (link) which specifies the field to be used for generating spelling suggestions. That field does not have a LowerCaseFilter in your schema.xml

Upvotes: 0

Related Questions