Spelling suggestions with django-haystack and Solr

I get "No" for spelling suggestions.

First, I set this parameter in the settings.py file:

HAYSTACK_INCLUDE_SPELLING = True

I rebuilt the index:

python manage.py rebuild_index

and updated it for a good grade

python manage.py update_index

Search is working correctly. When I search for β€œCharger”, it returns 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 is:

<html>
    <body>

        {{ test }}<p>
        {{ spelling_suggestion }}

    </body>
</html>

Still returns nothing:

[]

None

Obviously, I did not expect anything for {{test}}, but should I not get something for {{spelling_suggestion}}? What am I missing?

+3
source share
1 answer

I finally figured this out (with some help from the Haystack message group)

, . , views.py haystack ( def def_context):

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

{{suggest}}

+3

Source: https://habr.com/ru/post/1783413/


All Articles