solr 建议者未返回任何结果
我已经按照 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我能想到的一些事情可能会导致此问题:
源字段(“描述”)不正确 - 确保这确实是为拼写检查器播种术语的字段。甚至可能该字段是不同的情况(例如,“描述”而不是“描述”)。
schema.xml 中的源字段设置不正确,或者正在由导致源字典无效的过滤器进行处理。我使用一个单独的字段来为字典播种,并使用
将相关的其他字段复制到该字段。术语“烧烤”未出现在至少 5% 的记录中(您已通过添加
0.05
),因此不包含在查找字典中在 SpellCheckComponent 中,
true< /str>
设置意味着只有会产生更多结果的术语才会作为建议返回。根据 Suggester 文档,它具有不同的功能(按权重对建议进行排序),但可能值得将其切换为 false 以查看它是否导致问题。我的 schema.xml 的相关部分:
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 dictionaryIn 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:
问题可能是您正在查询
/suggest
而不是/spell
../建议/?q=烧烤
在我的设置中,我传入的字符串是:
/solr/spell?q=barbequ&spellcheck=true&spellcheck.collate=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.
请检查 schema.xml 中是否设置了术语参数,例如:
...重新启动 solr 并再次重新索引
Please check, if the term-parameter are set in the schema.xml, like:
...restart solr and reindex again