用 haystack 和 xapian 搜索?

发布于 11-29 14:51 字数 811 浏览 7 评论 0原文

我一直在尝试进行此搜索:

帖子的标题是“帮助我”,

在我的代码中是:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永不分离2024-12-06 14:51:19

您是否尝试过使用 auto_query 方法?例如

SearchQuerySet().auto_query(request.Get.copy()['search'])

Have you tried using the auto_query method? E.g

SearchQuerySet().auto_query(request.Get.copy()['search'])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文