django-haystack 和 Solr 的拼写建议
我收到的拼写建议为“无”。
首先,我在我的settings.py 文件中设置了这个:
HAYSTACK_INCLUDE_SPELLING = True
我已经重建了索引:
python manage.py rebuild_index
并更新了它以进行良好的测量
python manage.py update_index
搜索工作正常。当我搜索“充电器”时,它返回匹配的结果。所以在我的views.py中,我然后尝试了:
from haystack.query import SearchQuerySet
def testpage(request):
test_results = SearchQuerySet().auto_query('Chargr')
spelling_suggestion = test_results.spelling_suggestion()
return render_to_response('testpage.html', {
'test': test_results,
'spelling_suggestion': spelling_suggestion
})
但是,我的模板:
<html>
<body>
{{ test }}<p>
{{ spelling_suggestion }}
</body>
</html>
仍然没有返回任何内容:
[]
None
显然,我对 {{ test }} 没有任何期望,但是我不应该为 {{pelling_suggestion }} 得到一些东西吗?我缺少什么?
I'm getting "None" for spelling suggestions.
First, I have this set in my settings.py file:
HAYSTACK_INCLUDE_SPELLING = True
I have rebuilt the index:
python manage.py rebuild_index
and updated it for good measure
python manage.py update_index
The search works correctly. When I search for "Charger", it returns the results that match. So in my views.py, I then tried:
from haystack.query import SearchQuerySet
def testpage(request):
test_results = SearchQuerySet().auto_query('Chargr')
spelling_suggestion = test_results.spelling_suggestion()
return render_to_response('testpage.html', {
'test': test_results,
'spelling_suggestion': spelling_suggestion
})
However, my template:
<html>
<body>
{{ test }}<p>
{{ spelling_suggestion }}
</body>
</html>
Still returns nothing:
[]
None
Obviously, I expected nothing for {{ test }}, but shouldn't I get something for {{ spelling_suggestion }}? What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于弄清楚了这一点(在 Haystack 消息组的帮助下)
有一些细节 此处介绍必须进行的配置更改。此外,我必须向 haystack 的views.py 文件添加行(在 def extra_context 下):
然后我将 {{ suggest }} 添加到我的输出模板
I did finally figure this out (with some help from the Haystack message group)
There is some detail here on configuration changes that must be made. In addition, I had to add lines to haystack's views.py file (under def extra_context):
Then I added {{ suggest }} to my output template