# 当前分类中无法通过高级搜索以外的方式按用户搜索

**URL:** <https://meta.discourse.org/t/can-no-longer-search-by-user-in-current-category-outside-of-advanced-search/232401>\
**Category:** Feature\
**Created:** [2022年七月10日 02:10 UTC](https://meta.discourse.org/t/can-no-longer-search-by-user-in-current-category-outside-of-advanced-search/232401 "2022-07-10T02:10:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)\
**Post date:** [2022年七月10日 02:10 UTC](https://meta.discourse.org/t/can-no-longer-search-by-user-in-current-category-outside-of-advanced-search/232401/1 "2022-07-10T02:10:18Z")

</div>

我觉得这个功能以前有过但后来消失了，但如果它实际上从未存在过，请将其移至 #contribute:feature。

* * *

基本上，这两个选项（在当前类别中 / 在所有主题和帖子中）：

 ![image](https://global.discourse-cdn.com/meta/original/4X/0/a/4/0a49bd785ad933aad8f1ec9e3ea40de02abf2cf6.png)

在按用户名搜索时（无论是否附带文本），也应出现这两个选项。请注意，在这种情况下只有“所有主题和帖子”版本有效（尽管界面上并未说明这一点）。

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/6/c/c6c50354b2d02ef721191b05744a10757ccc8848.png)

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2022年七月11日 06:53 UTC](https://meta.discourse.org/t/can-no-longer-search-by-user-in-current-category-outside-of-advanced-search/232401/2 "2022-07-11T06:53:07Z")

</div>

这是一个合法的需求，我们等 Penar 休假回来再听听他的想法。我认为这有点是故意的，因为他不想让用户界面过于复杂。

（我给自己设置了一个下周的提醒）

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2022年七月17日 23:10 UTC](https://meta.discourse.org/t/can-no-longer-search-by-user-in-current-category-outside-of-advanced-search/232401/3 "2022-07-17T23:10:01Z")

</div>

抱歉，这里需要再等一周，我将设置另一个提醒。

---

<div class="post-metadata">

**Author:** ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)\
**Post date:** [2022年七月26日 14:50 UTC](https://meta.discourse.org/t/can-no-longer-search-by-user-in-current-category-outside-of-advanced-search/232401/5 "2022-07-26T14:50:11Z")

</div>

我相当确定这从未存在过。这是一个合理的请求，但在使用特殊字符（@ 和 #）时，要正确处理相当棘手。没有特殊字符，搜索只有两种可能的结果：当前类别或所有地方。使用“@”字符，我们会查询与“@”后面的字符串匹配的用户名，所以在许多情况下会有很多结果：

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/9/a/e9a0798088d65134d18a556b9280aeb6768fc37e.png)

因此，对于所请求的行为，我们需要检测用户搜索何时只返回一个结果，然后在您处于某个上下文中时显示上下文选项（在当前类别/所有地方）。这当然是可行的。

与此同时，您目前 _可以_ 组合使用特殊字符，所以如果您想在“Feature”类别中搜索用户“seanblue”的字符串，您可以输入：

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/a/d/cad4833196daf0941e22d516e37d0ad524af754f.png)

---

<div class="post-metadata">

**Author:** ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)\
**Post date:** [2022年七月26日 22:31 UTC](https://meta.discourse.org/t/can-no-longer-search-by-user-in-current-category-outside-of-advanced-search/232401/6 "2022-07-26T22:31:46Z")

</div>

> [@pmusaraj](#):
>
> 我相当确定这功能从未存在过。这是一个合理的需求，但在处理特殊字符（@ 和 #）时确实很难做到完美。如果没有特殊字符，搜索结果只有两种可能：当前分类或全部内容。使用 `@` 字符时，我们会查询用户名与 `@` 后的字符串匹配的结果，因此在很多情况下会有许多匹配项。

啊，我隐约记得之前讨论过这个问题……我想我最大的问题在于，旧版搜索（带有复选框，可切换在当前上下文中搜索或全局搜索）能够处理这种情况。从某种意义上说，那个更简单、外观不那么美观的版本功能更强大，因为无论搜索什么内容，你都可以轻松切换上下文。这是我更喜欢旧版的两个原因之一，尽管新版看起来更漂亮。（另一个原因是，现在 `Enter` 键默认执行全局搜索，但 90% 的情况下我希望进行上下文搜索。）

> [@pmusaraj](#):
>
> 因此，要实现所请求的行为，我们需要检测当用户搜索仅返回一个结果时，如果当前处于某个上下文中，则显示上下文选项（在当前分类 / 全部位置）。这当然是可以实现的。

看起来当仅搜索确切的用户名，特别是在当前主题中搜索时，它已经可以工作了。

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/1/8/218c6f5b94fbba934ab54c3a80ffcceee5c22739.png)

不过在分类页面却无法工作。

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/7/0/27031f3d12ff1f2d24d364cbb28dd2abd414b7b8.png)

不过总的来说，我认为在有确切匹配时，应尽可能支持更多功能。添加 `#contribute:feature` 可能像您建议的那样容易，但在当前主题中搜索则没那么直接。我刚刚注意到，在当前主题中搜索 `some text @seanblue` 可以工作，但搜索 `@seanblue some text` 却不行。所以我想，当前主题的部分功能至少已经部分实现了。

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/8/7/9879608a2d9944d5d5e48db7b365d5459c844bb1.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/b/b/9bb2fba087b32cd55355cbfae8a4a3166868100e.png)

总之，我刚才写的这些有点像是意识流。除了重新分离出上下文/全局切换（就像以前的复选框那样），我还没有想清楚除了“如果它总能工作就好了”之外的整体方案，也没有其他简单的处理所有情况的想法。
