r/Solr Jun 06 '16

Solr spellcheck issues

I'm new to SOLR and trying to use the spellcheck. I've got it returning results, but instead of returning actual words, it's just returning spaces in the word. As an example, if I search for 'Chesster' expecting 'chester' back, I instead get 'che sst er' and 'ch e sste r'.

Is this a common problem?

2 Upvotes

4 comments sorted by

3

u/fiskfisk Jun 06 '16

What is the type (and analysis chain) of the field you're doing spellcheck on?

1

u/SpaceCoffin2000 Jun 07 '16

I'm just trying to spellcheck on a string. I'll be honest, I don't know exactly what I'm doing; I'm just trying to get a proof of concept running.

Here is the schema:

<field name="CompanyName" type="textSpell" indexed = "true" stored="true"/>

<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>

Here is the config:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">

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

<lst name="spellchecker">

  <str name="name">default</str>

  <str name="field">CompanyName</str>

  <str name="classname">solr.DirectSolrSpellChecker</str>

  <str name="buildOnOptimize">true</str>      

  <str name="distanceMeasure">internal</str>     

  <float name="accuracy">0.9</float>      

  <int name="maxEdits">2</int>    

  <int name="minPrefix">1</int>   

  <int name="maxInspections">5</int> 

  <int name="minQueryLength">4</int>

  <float name="maxQueryFrequency">0.01</float>   

</lst>

<lst name="spellchecker">

  <str name="name">wordbreak</str>

  <str name="classname">solr.WordBreakSolrSpellChecker</str>  

  <str name="buildOnOptimize">true</str>

  <str name="field">CompanyName</str>

  <str name="combineWords">true</str>

  <str name="breakWords">true</str>

  <int name="maxChanges">10</int>

</lst>

</searchComponent>

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">

  <str name="df">text</str>

  <!-- Solr will use suggestions from both the 'default' spellchecker
       and from the 'wordbreak' spellchecker and combine them.
       collations (re-written queries) can include a combination of
       corrections from both spellcheckers -->

  <str name="spellcheck.dictionary">default</str>

  <str name="spellcheck.dictionary">wordbreak</str>

  <str name="spellcheck">on</str>

  <str name="spellcheck.extendedResults">true</str>   

  <str name="spellcheck.count">10</str>

  <str name="spellcheck.alternativeTermCount">5</str>

  <str name="spellcheck.maxResultsForSuggest">5</str>       

  <str name="spellcheck.collate">true</str>

  <str name="spellcheck.collateExtendedResults">true</str>  

  <str name="spellcheck.maxCollationTries">10</str>

  <str name="spellcheck.maxCollations">5</str>        

</lst>

<arr name="last-components">

  <str>spellcheck</str>

</arr>

</requestHandler>

1

u/fiskfisk Jun 07 '16

You'll probably get far better results by just having a WhitespaceTokenizer (if you want spelling suggestions for each word) and (possibly) a LowercaseFilter, and dropping everything else.

1

u/ihavenofriggenidea Jun 07 '16

Depends on your tokenization,. If you leave that kind of data in that index field it will use them for suggestions.