django-haystack 和 Solr 的拼写建议

发布于 2024-10-10 03:57:12 字数 981 浏览 0 评论 0原文

我收到的拼写建议为“无”。

首先,我在我的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 技术交流群。

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

发布评论

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

评论(1

初熏 2024-10-17 03:57:12

我终于弄清楚了这一点(在 Haystack 消息组的帮助下)

有一些细节 此处介绍必须进行的配置更改。此外,我必须向 haystack 的views.py 文件添加行(在 def extra_context 下):

spelling = self.results.spelling_suggestion(self.query)
return {'suggestion': spelling, . . .

然后我将 {{ 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):

spelling = self.results.spelling_suggestion(self.query)
return {'suggestion': spelling, . . .

Then I added {{ suggest }} to my output template

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