Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

spell checking - solr suggester not returning any results

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...