2

I have a list of misspelled and corrected words in synonyms.txt file. How can I use that in solr for spelling suggestions?

e.g. synonyms.txt contains following entries:

laptap => laptop
delll => dell

When I query "laptap" to solr server, I should get suggestion as "did you mean: laptop?".

I know the schema.xml will look like this:

<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
<analyzer type="index">
   <tokenizer class="solr.StandardTokenizerFactory"/>
     <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
     <filter class="solr.LowerCaseFilterFactory"/>
     <filter class="solr.StandardFilterFactory"/>
</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.LowerCaseFilterFactory"/>
     <filter class="solr.StandardFilterFactory"/>
</analyzer> 
</fieldType>

What about solrconfig.xml? I do not want to use index since I already have a list. Any idea?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
qwerty
  • 31
  • 1
  • 4

1 Answers1

2

Update to accomodate the requirement of not creating an index/dictionary from the flat file:

  1. Look at the Suggester functionality that was added in Solr 3.1
  2. Implement a Custom SpellCheckComponent that has the desired behavior (although I think that Suggester is close to what you want).

Previous suggestion:

Here is an good article on setting up spell checking in Solr, that includes how to configure file based spell checking. You should be able to follow this and replace the spellings.txt file in the sample configuration with your synonyms.txt file.

Getting started Spell Checking with Apache Lucene and Solr

Paige Cook
  • 22,415
  • 3
  • 57
  • 68
  • FileBasedSpellChecker creates and uses a spelling dictionary based off a flat file which is same as creating an index. I have a mapping of misspelled words to corrected words and I would like to use these mappings and not search in the index. I am not sure how I can use FileBasedSpellChecker to use my file for suggestions. – qwerty Sep 13 '11 at 01:22
  • Did not realize that the FileBasedSpellChecker creates a spelling dictionary off the flat file. – Paige Cook Sep 13 '11 at 11:21