# 在部分类别中搜索功能

**URL:** https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385
**Category:** Support
**Tags:** search
**Created:** [2026年四月10日 10:47 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385 "2026-04-10T10:47:19Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月10日 10:47 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/1 "2026-04-10T10:47:20Z")

</div>

我想知道搜索函数中是否存在一个参数，该参数可以限定只在特定类别中进行搜索。是的，我知道可以通过在搜索栏中输入类别名称来实现，但我希望简化用户的使用体验。

谢谢

---

<div class="post-metadata">

### Author: ![David\_Ghost](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@David\_Ghost](https://meta.discourse.org/u/David_Ghost)
#### Post date: [2026年四月10日 10:56 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/2 "2026-04-10T10:56:07Z")

</div>

您可以使用 [高级标题搜索](https://meta.discourse.org/t/advanced-header-search/194093) 来实现。以下是一个示例配置：

> [@Tris20](#):
>
> 以下是我在我们的 GitLab 分类中所做的示例。您可以在标题搜索栏中看到，一旦我们输入搜索词（在本例中为 pipeline），您就可以搜索 GitLab 论坛（点击评论按钮）、GitLab 文档（书本图标）、GitLab 项目（工单图标）以及 GitLab Python 库。
> 
> ![image](https://global.discourse-cdn.com/meta/original/4X/c/6/9/c69ac2c2fa524ec16ebc28a32fe27144645fc21e.png)
> 
> 以下是允许您搜索 GitLab 论坛的参数示例。

---

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月10日 11:42 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/3 "2026-04-10T11:42:25Z")

</div>

谢谢你的信息，但我不想进行外部搜索，只想在 Discourse 的某些分类中搜索。

---

<div class="post-metadata">

### Author: ![David\_Ghost](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@David\_Ghost](https://meta.discourse.org/u/David_Ghost)
#### Post date: [2026年四月10日 12:15 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/4 "2026-04-10T12:15:07Z")

</div>

这正是我的意思。你需要用你分类的链接来配置它，并加上“q?=”，如果我没记错的话。这是来自 Meta 的一个示例链接：[Search results for 'test #support:self-hosting' - Discourse Meta](https://meta.discourse.org/search?q=test%20%23support%3Aself-hosting)

你需要用你分类的图标来配置它。

---

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月10日 12:31 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/5 "2026-04-10T12:31:55Z")

</div>

> [@David\_Ghost](#):
>
> q?=

好的，我之前没理解：sweat\_smile：这个原理。谢谢提供的信息，那我再去仔细研究一下，谢谢：+1:

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2026年四月10日 14:53 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/6 "2026-04-10T14:53:32Z")

</div>

当您在被搜索的分类中时，搜索下拉菜单会提供“在当前分类中搜索”选项：

 ![Screenshot 2026-04-10 at 7.50.42 AM](https://global.discourse-cdn.com/meta/original/4X/d/9/a/d9aac719848eb79db80bfb39bbaaed8318116ec4.png)

您也可以教他们使用 `/filter` 功能：

 ![Screenshot 2026-04-10 at 7.51.42 AM](https://global.discourse-cdn.com/meta/original/4X/2/5/c/25c53870465eabc6f9066010a3d72752abd272b8.png)

---

<div class="post-metadata">

### Author: ![David\_Ghost](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@David\_Ghost](https://meta.discourse.org/u/David_Ghost)
#### Post date: [2026年四月10日 17:12 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/7 "2026-04-10T17:12:43Z")

</div>

我刚刚做了一个测试，如果你为 “/search?context=category&context\_id=YOUR\_CATEGORY\_ID\_HERE&q=” 设置“前缀”，它就能正常工作。这是一个预览，使用类别 ID 8 并搜索“lara”：

 ![preview](https://global.discourse-cdn.com/meta/original/4X/6/2/6/626007d654fd33a07492b6979b423ffe68f0e365.png)

---

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月10日 18:00 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/8 "2026-04-10T18:00:01Z")

</div>

谢谢你的帮助，我会测试一下：+1：

---

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月10日 18:20 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/9 "2026-04-10T18:20:25Z")

</div>

我测试过了，感谢 @David_Ghost 的帮助，但我觉得它的操作不够直观。我打算尝试开发另一种方式。要知道，用户总是将一切与其他软件进行比较，而要让他们前来或留下已经相当困难了：sweat\_smile。

不过还是感谢大家的帮助：+1:

---

<div class="post-metadata">

### Author: ![Tris20](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tris20/32/264639_2.png) [@Tris20](https://meta.discourse.org/u/Tris20)
#### Post date: [2026年四月14日 07:45 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/10 "2026-04-14T07:45:36Z")

</div>

你好 @gilles，

> 我已经测试过了，并感谢 @David_Ghost 提供的帮助；不过，我觉得它的用法不够直观。

我在想，你是否能提供更多细节，说明你在这里尝试了什么，以及得到了什么结果。也许你可以分享一些截图？

---

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月14日 11:42 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/11 "2026-04-14T11:42:18Z")

</div>

你好 @Tris20，

我想要一个搜索功能，能在论坛页面上同时搜索两个分类，而不跳转到其他页面。如果我没理解错的话，目前会出现两个搜索栏，每种搜索类型对应一个图标。本来用户就觉得 Discourse 的使用有点复杂，所以我正尝试简化操作流程 🤣。现在的问题是，用户总是把各种东西都拿来比较。也许是我对这个组件的使用方式不对。

我想要的效果是：输入搜索词后，搜索引擎仅在被配置的两个分类中进行搜索。

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [2026年四月14日 12:47 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/12 "2026-04-14T12:47:42Z")

</div>

我认为最好的选择是

> [@Lilly](#):
>
> `/filter` 功能：
> 
> ![Screenshot 2026-04-10 at 7.51.42 AM](https://global.discourse-cdn.com/meta/original/4X/2/5/c/25c53870465eabc6f9066010a3d72752abd272b8.png)

你可以在 Meta 上尝试以下查询：

```plaintext
Simple category:general,marketplace

```

这将返回 #General 和 #Marketplace 分类中包含单词“simple”的主题。

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2026年四月14日 12:57 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/13 "2026-04-14T12:57:52Z")

</div>

这就是全页搜索的作用，它让普通用户也能轻松使用筛选条件进行高级搜索：

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/d/6/dd68e26006178e46596de694662a06d164e28474.jpeg)

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2026年四月14日 13:06 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/14 "2026-04-14T13:06:03Z")

</div>

你能向我解释一下高级搜索如何帮助用户同时跨多个类别进行搜索吗？我记得在维基和文档拆分时曾提出过这个问题，但此后似乎没有任何改动。

> [@New homes for official and community documentation](https://meta.discourse.org/t/new-homes-for-official-and-community-documentation/322620/10):
>
> I think this rather highlights things we can improve in the Discourse UI. Notably, allowing multiple categories to be selected in the advanced search, amongst other things. This presents a great opportunity and extra motivation to work on updates like that, so we’ll see what we can do there! We’ll discuss this, and I’ll circle back here with any updates.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2026年四月14日 13:15 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/15 "2026-04-14T13:15:03Z")

</div>

> [@Moin](#):
>
> 你能向我解释一下高级搜索如何帮助用户同时跨多个类别进行搜索吗？

你能指出原帖（OP）在哪里询问了 **同时** 在特定类别中搜索的内容吗？

根据翻译，我理解这是指能够将搜索限制在特定类别中，而这与通过搜索类别运算符已经实现的功能相同，只是方式更加直观。

> [@gilles](#):
>
> 是的，我知道可以通过在搜索栏中输入类别名称来实现，但我想让我的用户操作更简单。

也许我在翻译中漏掉了什么 🤔

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2026年四月14日 13:26 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/16 "2026-04-14T13:26:42Z")

</div>

> [@Falco](#):
>
> 你能指出原帖中哪里提到要 **同时** 搜索特定类别吗？

至少英文翻译里写的是“同时”。

> [@gilles](#):
>
> 我在寻找一个能同时搜索两个类别的搜索功能。

---

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月14日 15:36 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/17 "2026-04-14T15:36:41Z")

</div>

我不想制造问题，我知道找到完美的解决方案并不容易，尤其是对我来说，问题在于那些不习惯论坛、更习惯聊天的用户。我知道默认有过滤器，这对我完全没问题，因为我习惯了，但我会想到新手用户，而且他们往往很着急 😅

我正在努力为这些用户寻找解决方案。我的论坛专注于桌游，我有多个类别涵盖各种话题，但只有两个类别包含游戏资料卡。

我希望搜索栏仅用于搜索游戏资料卡。

假设我有四个类别：cat1、cat2、cat3 和 cat4，其中 cat2 和 cat3 存放我的游戏资料卡。

当用户输入“游戏1”时，搜索栏应默认仅在 cat2 和 cat3 中进行搜索。

这就是我的难题。

对我来说，这本身不是问题，因为我熟悉 Discourse 的解决方案，但许多用户不想自找麻烦。他们想要一个快速、简单的解决方案。

对我来说，最大的问题是如何简化用户的使用体验。我非常喜欢 Discourse，我认为社区很棒，Discourse 的开发团队也很出色。我欣赏你们所做的一切，但 Discourse 需要适应不同的使用场景，这并不容易，我也完全理解这一点。

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2026年四月14日 15:43 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/18 "2026-04-14T15:43:15Z")

</div>

调整分类设置中的搜索优先级能解决您的问题吗？这样可以大幅提高用户找到该分类下主题的可能性。您可以在 Meta 上体验这一点，搜索 [support](https://meta.discourse.org/search?expanded=true&q=%23support)，它的优先级较低，因此您会看到更多来自子分类（如自托管）的主题。

 ![Screenshot20260414173914Firefox](https://global.discourse-cdn.com/meta/original/4X/6/5/6/656edfe34881844145c5d005a0ebe6e6213d4378.jpeg)

否则，我认为您需要一个自定义主题组件来改变用户的搜索体验。

---

<div class="post-metadata">

### Author: ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)
#### Post date: [2026年四月14日 15:53 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/20 "2026-04-14T15:53:25Z")

</div>

谢谢 @Moin，我试试看：+1:

@Moin 太棒了，我之前不知道这个功能。它有效：+1:

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2026年五月14日 15:53 UTC](https://meta.discourse.org/t/fonction-recherche-dans-certaines-categories/400385/21 "2026-05-14T15:53:42Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
