solr 建议者不返回任何结果 [英] solr suggester not returning any results

查看:22
本文介绍了solr 建议者不返回任何结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经关注了 solr wiki 文章的建议者几乎到了这里:http://wiki.apache.org/solr/Suggester.我的 solrconfig.xml 中有以下 xml:

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

我只得到以下结果xml:

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?

推荐答案

我能想到的一些可能会导致此问题的事情:

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").

schema.xml 中的源字段设置不正确或正在被过滤器处理,导致源字典无效.我使用一个单独的字段来为字典提供种子,并使用 将相关的其他字段复制到该字段.

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.

术语烧烤"未出现在至少 5% 的记录中(您已通过包含 <float name="threshold">0.05</float>),因此不包含在查找字典中

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

在 SpellCheckComponent 中,<str name="spellcheck.onlyMorePopular">true</str> 设置意味着只有会产生更多结果的术语才会作为建议返回.根据 Suggester 文档,这具有不同的功能(按重量对建议进行排序),但可能值得将其切换为 false 以查看是否是导致问题的原因.

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.

我的 schema.xml 的相关部分:

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>

这篇关于solr 建议者不返回任何结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆