views:

216

answers:

1

This questions is about Django Haystack, with Whoosh backend. I would like to use spelling suggestion in my search. The problem is that it is suggesting TOO much.

Say I have two models: Apples and Oranges.

If I have somethine like this:

result = SearchQuerySet().models(Apples).filter(
    content=escaped_value).spelling_suggestion(escaped_value)

it will actually LOOK into Oranges model and return a spelling suggestion from that! It seems like models(Apples) restriction does not work.

I have indexes setup for both models, with "text" attribute as document=True. My spelling is ON. I am using Whoosh as backend.

+1  A: 

This is the problem because Haystack creates spelling suggestions based on the fields which have document=True (which in my case are the primary search field in all models and they have the same name). So it does not care about models at all and alway searches across all the knowledgebase.

I filed an issue with haystack and brought it up on the discussion board. Dev is very helpful: http://groups.google.com/group/django-haystack/browse%5Fthread/thread/025e5ed42ccde8b9#

Issue: http://github.com/toastdriven/django-haystack/issues/#issue/124

drozzy