我已经设置了一个django-oscar项目,并按照documentation在它上面启用了solr4.7.2。
Solr似乎运行得很好。测试我得到的'exxample‘(localhost:8983/solr/collection1/spell?spellcheck.q=exxample&spellcheck=true>)的建议:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">10</int>
</lst>
<result name="response" numFound="0" start="0"/>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="exxampl">
<int name="numFound">1</int>
<int name="startOffset">0</int>
<int name="endOffset">8</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>
<str name="word">exampl</str>
<int name="freq">2</int>
</lst>
</arr>
</lst>
<bool name="correctlySpelled">false</bool>
<lst name="collation">
<str name="collationQuery">exampl</str>
<int name="hits">2</int>
<lst name="misspellingsAndCorrections">
<str name="exxampl">exampl</str>
</lst>
</lst>
</lst>
</lst>
</response>我还启用了OSCAR_SEARCH_FACETS来确保Solr已经被Django-Oscar正确注册,而且看起来运行得很好。
然而,当我在django-oscar中对一个简单的拼写错误进行测试搜索时,我得到了0个返回的搜索结果,没有任何建议。我不知道下一步该做什么。
如果您能帮忙,我们将不胜感激!
发布于 2017-08-21 16:00:48
我已经设法解决了这个问题。我将在Django-Oscar上使用拼写建议编写我的完整解决方案来设置Solr,因为设置过程需要对官方文档中描述的过程进行调整。这也是我第一次使用Solr (或任何搜索引擎),所以不要期待一些专家的指导,只是关于如何在Oscar上启动和运行Solr的指导。
我使用的是Oscar 1.5和Solr 4.7.2 (解决方案也适用于4.10.4 ...不确定其他版本)。按照documentations执行所有操作-请注意,低于1.5的Oscar版本的说明略有不同。
一旦您安装并运行了Solr,您就可以在Solr服务器上测试查询@ localhost:8983/solr/collection1/spell?spellcheck.q=your搜索查询在这里;没有括号&spellcheck=true>。需要是您的数据库中的一个词-无论是在产品描述或产品名称。
您将得到一个错误结果,指出Analyzer需要是相同类型的。通过编辑位于./solr-4.7.2/example/solr/collection1/conf/solrconfig.xml.的solrconfig.xml文件来修复此问题搜索<str name="field">,并将每个未注释的实例更改为<str name="field">text</str> -您也可以将每个实例更改为<str name="field">title</str>,但这仅限于在标题中找到的单词。重新启动Solr服务器。这些更改将消除Analyzer错误,您的Solr服务器现在将开始显示结果,但它们还不会输入到您的Oscar站点。
要解决此问题,您需要对同一solrconfig.xml文件进行另一次调整。搜索<requestHandler name="/select" class="solr.SearchHandler">,在此请求处理程序的底部包含以下代码:
<arr name="last-components">
<str>spellcheck</str>
</arr>重新启动服务器。现在你在你的Oscar网站上有了拼写建议。希望其他人能发现这一点很有帮助。就像我说的--这是我第一次使用Solr。如果有人想在Oscar上添加或扩展Solr功能,那就太好了。
https://stackoverflow.com/questions/45718926
复制相似问题