【问题标题】:Spelling Suggestions with django-haystack and Solrdjango-haystack 和 Solr 的拼写建议
【发布时间】:2011-01-04 14:42:58
【问题描述】:

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

首先,我在我的 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 }} 没有任何期望,但我不应该为 {{ spelling_suggestion }} 得到什么吗?我错过了什么?

【问题讨论】:

    标签: django spell-checking django-haystack


    【解决方案1】:

    我终于弄明白了(在 Haystack 消息组的帮助下)

    here 有一些关于必须进行的配置更改的详细信息。另外,我必须在 haystack 的 views.py 文件中添加行(在 def extra_context 下):

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

    然后我将 {{Suggest }} 添加到我的输出模板中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-26
      • 2014-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多