Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

solr suggester not returning any results

Tags:

I've followed the solr wiki article for suggester almost to the T here: http://wiki.apache.org/solr/Suggester. I have the following xml in my solrconfig.xml:

<searchComponent class="solr.SpellCheckComponent" name="suggest">       <lst name="spellchecker">       <str name="name">suggest</str>       <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>       <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>       <str name="field">description</str>       <float name="threshold">0.05</float>       <str name="buildOnCommit">true</str>     </lst>  </searchComponent>  <requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">     <lst name="defaults">       <str name="spellcheck">true</str>       <str name="spellcheck.dictionary">suggest</str>       <str name="spellcheck.onlyMorePopular">true</str>       <str name="spellcheck.count">5</str>       <str name="spellcheck.collate">true</str>     </lst>     <arr name="components">       <str>suggest</str>     </arr>  </requestHandler>  

However, when I run the following query (or something similar):

../suggest/?q=barbequ 

I only get the following result xml back:

<response>    <lst name="responseHeader">       <int name="status">0</int>       <int name="QTime">78</int>    </lst>    <lst name="spellcheck">       <lst name="suggestions"/>    </lst> </response> 

As you can see, this isn't very helpful. Any suggestions to help resolve this?

like image 739
Marquis Avatar asked Jul 11 '11 16:07

Marquis


1 Answers

A couple of things I can think of that might cause this problem:

  • The source field ("description") is incorrect - ensure that this is indeed the field that seeds terms for your spell checker. It could even be that the field is a different case (eg. "Description" instead of "description").

  • The source field in your schema.xml is not set up correctly or is being processed by filters that cause the source dictionary to be invalid. I use a separate field to seed the dictionary, and use <copyfield /> to copy relevant other fields to that.

  • The term "barbeque" doesn't appear in at least 5% of records (you've indicated this requirement by including <float name="threshold">0.05</float>) and therefore is not included in the lookup dictionary

  • In SpellCheckComponent the <str name="spellcheck.onlyMorePopular">true</str> setting means that only terms that would produce more results are returned as suggestions. According to the Suggester documentation this has a different function (sorting suggestions by weight) but it might be worth switching this to false to see if it is causing the issue.

Relevant parts of my schema.xml:

<schema>     <types>         <!-- Field type specifically for spell checking -->         <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>     </types>     <fields>         <field name="spell" type="textSpell" indexed="true" stored="false" multiValued="true" />     </fields>      <!-- Copy fields which are used to seed the spell checker -->     <copyField source="name" dest="spell" />     <copyField source="description" dest="spell" /> <schema> 
like image 92
David Duffett Avatar answered Oct 13 '22 00:10

David Duffett