solr 建议者未返回任何结果

发布于 2024-11-19 14:57:00 字数 1736 浏览 4 评论 0原文

我已经按照 solr wiki 文章的建议几乎到了这里: http://wiki.apache.org /solr/Suggester。我的 solrconfig.xml 中有以下 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> 

但是,当我运行以下查询(或类似的查询)时:

../suggest/?q=barbequ

我只得到以下结果 xml:

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

如您所见,这不是很有帮助。有什么建议可以帮助解决这个问题吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱的故事 2024-11-26 14:57:01

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

  • 源字段(“描述”)不正确 - 确保这确实是为拼写检查器播种术语的字段。甚至可能该字段是不同的情况(例如,“描述”而不是“描述”)。

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

  • 术语“烧烤”未出现在至少 5% 的记录中(您已通过添加 0.05),因此不包含在查找字典中

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

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

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>
谈下烟灰 2024-11-26 14:57:01

问题可能是您正在查询 /suggest 而不是 /spell


../建议/?q=烧烤

在我的设置中,我传入的字符串是:


/solr/spell?q=barbequ&spellcheck=true&spellcheck.collat​​e=true

第一次进行拼写检查时,您需要包含


&spellcheck.build=true
顺便说一句,

我正在 solr 4 上运行。因此,也许 /suggest 是一个完全不同的端点,它可以做其他事情。如果是这样,请道歉。

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.

你在我安 2024-11-26 14:57:01

请检查 schema.xml 中是否设置了术语参数,例如:

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

...重新启动 solr 并再次重新索引

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文