searching with haystack and xapian?
I've been trying to do this search:
the post's title is 'help me'
in my code it's:
SearchQuerySet().filter(title=request.Get.copy()['search'])
so if I search 'help', 'me', or 'help me' I get the post, however if I search 'me help', I don't. I want to search 'me help' and still get the post. Or开发者_JAVA技巧 if a post's title is 'help me please' and I search 'help please', I'll still get the post...
So I searched a bit on stackoverflow... and reached a post here: Django + Haystack how to do this search
I followed the accepted answer's two suggestions
however, when I did:
Change HAYSTACK_DEFAULT_OPERATOR within your settings.py to be OR.
when I search 'me help', I got all results, even those without 'help' or 'me'
when I did:
SearchQuerySet.filter_or(**kwargs)
nothing really changed, searching 'help', 'me', 'help me' worked, but 'me help' still didn't.
I'm sure the answer's obvious, but I new to haystack... So how do I get the query (searching 'me help') to get the post ('help me')?
Have you tried using the auto_query method? E.g
SearchQuerySet().auto_query(request.Get.copy()['search'])
精彩评论