solr suggester not returning any results

匆匆过客 提交于 2019-11-28 06:22:20

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>

Could the problem be that you're querying /suggest instead of /spell

../suggest/?q=barbequ

In my setup this the string I pass in:

/solr/spell?q=barbequ&spellcheck=true&spellcheck.collate=true

And the first time you do a spellcheck you need to include

&spellcheck.build=true

I'm running on solr 4 btw. So, perhaps /suggest is an entirely different endpoint that does something else. If so, apologize.

Please check, if the term-parameter are set in the schema.xml, like:

<field name="TEXT" type="text_en" indexed="true" stored="true" multiValued="true" 
                   termVectors="true"
                   termPositions="true"
                   termOffsets="true"/>

...restart solr and reindex again

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!