# 使用多词查询搜索功能不符合预期

**URL:** <https://meta.discourse.org/t/searching-with-multi-word-query-does-not-function-as-expected/239804>\
**Category:** Support\
**Tags:** search\
**Created:** [2022年九月22日 19:57 UTC](https://meta.discourse.org/t/searching-with-multi-word-query-does-not-function-as-expected/239804 "2022-09-22T19:57:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lollop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lollop/32/274014_2.png) [@lollop](https://meta.discourse.org/u/lollop)\
**Post date:** [2022年九月22日 19:57 UTC](https://meta.discourse.org/t/searching-with-multi-word-query-does-not-function-as-expected/239804/1 "2022-09-22T19:57:45Z")

</div>

我的 Discourse 站点的通用搜索功能在我输入多词查询时，表现不如预期。

例如：我的站点有一个标题为“Two words in this topic title”的主题。当我输入“two”到搜索栏并按回车键时，这个主题会作为搜索结果之一出现，正如我所预期的那样。然而，当我添加一个不是主题一部分的词语时——例如“two ex”、“two anything”等——并按回车键，我就不再获得任何搜索结果。

即使是多词查询，我也期望仍然能看到该主题，因为它仍然匹配“two”这个词。有人能帮我解释一下 Discourse 的搜索是如何工作的吗？是否有办法调整它以处理这种情况？即使我无法更改任何设置，仅仅了解它的工作原理和预期行为也会有帮助。

我阅读了[搜索控制器](https://github.com/discourse/discourse/blob/94cd5ac0b1b654ba55028c3cdead1bfb40af2991/app/controllers/search_controller.rb)背后的代码，但未能找到答案。

另一个类似的主题，也没有回答这个问题：[如何在 Discourse 上搜索](https://meta.discourse.org/t/how-to-search-on-discourse/195459)

---

<div class="post-metadata">

**Author:** ![jessii](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jessii/32/354015_2.png) [@jessii](https://meta.discourse.org/u/jessii)\
**Post date:** [2022年九月27日 23:43 UTC](https://meta.discourse.org/t/searching-with-multi-word-query-does-not-function-as-expected/239804/2 "2022-09-27T23:43:32Z")

</div>

嘿！

目前搜索栏无法实现此功能。这是另一个有类似问题的帖子：

> [@Any way to "OR" search terms?](https://meta.discourse.org/t/any-way-to-or-search-terms/53982):
>
> Seems like my discourse site is using a pretty aggressive “AND” semantics, such that if I have (for example) 5 documents which contain either ‘foo’ or ‘bar’, but only one which contains ‘foo bar’, and I search for ‘foo bar’ (no quotes) I get only the one page, where I’d like to see that one first, but then also see the others in some kind of descending order (relevance or recency or whatever). I can’t see a way through the Advanced Search page or otherwise to specify that the terms should be lo…

可以搜索部分单词、复数形式或在同一主题中但并非相邻出现的两个单词（但是，主题必须同时包含这两个单词才能在结果中列出）。
