用 haystack 和 xapian 搜索?
我一直在尝试进行此搜索:
帖子的标题是“帮助我”,
在我的代码中是:
SearchQuerySet().filter(title=request.Get.copy()['search'])
所以如果我搜索“帮助”、“我”或“帮助我”,我会得到该帖子,但是如果我搜索“我帮忙”,我不帮忙。我想搜索“我的帮助”并仍然得到该帖子。或者,如果某个帖子的标题是“请帮帮我”,而我搜索“请帮帮我”,我仍然会收到该帖子...
所以我在 stackoverflow 上进行了一些搜索...并在此处找到了一个帖子: Django + Haystack 如何进行此搜索
我遵循了接受的答案的两个 然而,建议
,当我这样做时:
Change HAYSTACK_DEFAULT_OPERATOR within your settings.py to be OR.
当我搜索“我帮助”时,我得到了所有结果,即使是那些没有“帮助”或“我”的结果
:当我
SearchQuerySet.filter_or(**kwargs)
搜索“帮助”,“我”,“帮助我”时,没有任何真正改变'有效,但“我帮忙”仍然没有效果。
我确信答案是显而易见的,但我是干草堆新手......那么我如何获取查询(搜索“我帮助”)来获取帖子(“帮助我”)?
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 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')?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您是否尝试过使用 auto_query 方法?例如
Have you tried using the auto_query method? E.g