# 搜索讨论

可以在 GitHub 上搜索讨论，并使用搜索限定符缩小结果范围。

## 关于搜索讨论

可以跨所有 GitHub 全局搜索讨论，也可以在特定组织或存储库内搜索讨论。 有关详细信息，请参阅“[关于在GitHub上的搜索](/zh/enterprise-server@3.22/search-github/getting-started-with-searching-on-github/about-searching-on-github)”。

> \[!TIP]
>
> * 本文包含 GitHub.com 网站上示例搜索的链接，但你可以在任何 GitHub 平台中使用相同的搜索筛选器。 在链接的示例搜索中，将 `github.com` 替换为 GitHub 平台的主机名。
> * 有关可以添加到任何搜索限定符以进一步改善结果的搜索语法列表，请参阅 [了解搜索语法](/zh/enterprise-server@3.22/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax)。
> * 对多个字词的搜索词使用引号。 例如，如果要搜索具有标签“In progress”的问题，可搜索 `label:"in progress"`。 搜索不区分大小写。

## 按标题、正文或评论搜索

使用 `in` 限定符可将讨论搜索范围限制在标题、正文或评论中。 您还可以组合限定符来搜索标题、正文或注释的组合。 省略 `in` 限定符时，GitHub 将搜索标题、正文和评论。

| 限定符                                                                                                                           | 示例 |
| :---------------------------------------------------------------------------------------------------------------------------- | :- |
| `in:title`                                                                                                                    |    |
| \[                                                                                                                            |    |
| **welcome in:title**]\(<https://github.com/search?q=welcome+in%3Atitle&type=Discussions>) 匹配标题中包含“welcome”的讨论。                |    |
| `in:body`                                                                                                                     |    |
| \[                                                                                                                            |    |
| **onboard in:title,body**]\(<https://github.com/search?q=onboard+in%3Atitle%2Cbody&type=Discussions>) 匹配标题或正文中包含“onboard”的讨论。 |    |
| `in:comments`                                                                                                                 |    |
| \[                                                                                                                            |    |
| **thanks in:comments**]\(<https://github.com/search?q=thanks+in%3Acomment&type=Discussions>) 匹配评论中包含“thanks”的讨论。              |    |

## 在用户或组织的仓库内搜索

要在特定用户或组织拥有的所有存储库中搜索讨论，可使用 `user` 或 `org` 限定符。 要在特定存储库中搜索讨论，可使用 `repo` 限定符。

| 限定符                                                                                                                                                                                         | 示例 |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :- |
| <code>user:<em>USERNAME</em></code>                                                                                                                                                         |    |
| \[                                                                                                                                                                                          |    |
| **user:octocat feedback**]\(<https://github.com/search?q=user%3Aoctocat+feedback&type=Discussions>) 匹配来自 @octocat 所拥有存储库中包含单词“feedback”的讨论。                                                 |    |
| <code>org:<em>ORGNAME</em></code>                                                                                                                                                           |    |
| \[                                                                                                                                                                                          |    |
| **org：github**]\(<https://github.com/search?q=org%3Agithub&type=Discussions&utf8=%E2%9C%93)匹配GitHub组织拥有的存储库中的讨论。>                                                                           |    |
| <code>repo:<em>USERNAME/REPOSITORY</em></code>                                                                                                                                              |    |
| \[                                                                                                                                                                                          |    |
| **repo:nodejs/node created:<2021-01-01**]\(<https://github.com/search?q=repo%3Anodejs%2Fnode+created%3A%3C2020-01-01&type=Discussions>) 匹配来自 @nodejs 的 Node.js 运行时项目、且创建时间早于 2021 年 1 月的讨论。 |    |

## 按开放或关闭状态搜索

可以使用 `is` 限定符基于讨论处于打开还是关闭状态对其进行筛选。

| 限定符                                                                                                                                                     | 示例 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | -- |
| `is:open`                                                                                                                                               |    |
| \[                                                                                                                                                      |    |
| **performance is:open is:discussion**]\(<https://github.com/search?q=is%3Adiscussion+performance+is%3Aopen&type=discussions>) 匹配包含单词“performance”的开放讨论。 |    |
| `is:closed`                                                                                                                                             |    |
| \[                                                                                                                                                      |    |
| **android is:closed**]\(<https://github.com/search?q=android+is%3Aclosed&type=discussions>) 匹配包含单词“android”的已关闭讨论。                                      |    |

## 根据讨论是否得到答复进行搜索

可以使用 `is` 限定符搜索已回答的讨论。

| 限定符                                                                                                                                                              | 示例 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -- |
| `is:answered`                                                                                                                                                    |    |
| \[                                                                                                                                                               |    |
| **performance is:answered is:discussion**]\(<https://github.com/search?q=is%3Adiscussion+performance+is%3Aanswered&type=discussions>) 匹配包含单词“performance”的已回答讨论。 |    |
| `is:unanswered`                                                                                                                                                  |    |
| **android is:unanswered** 匹配包含“android”一词的未回答的讨论。                                                                                                                |    |

## 根据讨论是否已锁定来进行搜索

可以使用 `is` 限定符搜索已锁定的讨论。 有关详细信息，请参阅“[主持讨论](/zh/enterprise-server@3.22/discussions/managing-discussions-for-your-community/moderating-discussions)”。

| 限定符                                                                                                                                                               | 示例 |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -- |
| `is:locked`                                                                                                                                                       |    |
| **"code of conduct" is:locked is:discussion** 匹配包含“行为准则”一词的已锁定的讨论。                                                                                                |    |
| `is:unlocked`                                                                                                                                                     |    |
| \[                                                                                                                                                                |    |
| **code of conduct is:unlocked is:discussion**]\(<https://github.com/search?q=%22code+of+conduct%22+is%3Aunlocked&type=discussions>) 匹配包含“code of conduct”且未锁定的讨论。 |    |

## 按仓库可见性过滤

可使用 `is` 限定符，按包含讨论的存储库的可见性进行筛选。 有关详细信息，请参阅“[关于仓库](/zh/enterprise-server@3.22/repositories/creating-and-managing-repositories/about-repositories#about-repository-visibility)”。

| 限定符                                                                                                                                  | 示例 |
| :----------------------------------------------------------------------------------------------------------------------------------- | :- |
| `is:public`                                                                                                                          |    |
| [is:public\*\*\*\*](https://github.com/search?q=is%3Apublic\&type=Discussions) 会匹配公共存储库中的讨论。                                         |    |
|                                                                                                                                      |    |
| `is:private`                                                                                                                         |    |
| [is:private tiramisu\*\*\*\*](https://github.com/search?q=is%3Aprivate+tiramisu\&type=Discussions) 会匹配你可以访问的专用存储库中包含“tiramisu”一词的讨论。 |    |

## 按作者搜索

`author` 限定符查找由特定用户创建的讨论。

| 限定符                                                                                                                            | 示例 |
| :----------------------------------------------------------------------------------------------------------------------------- | :- |
| <code>author:<em>USERNAME</em></code>                                                                                          |    |
| \[                                                                                                                             |    |
| **cool author:octocat**]\(<https://github.com/search?q=cool+author%3Aoctocat&type=Discussions>) 匹配由 @octocat 创建且包含单词“cool”的讨论。 |    |
| `in:body`                                                                                                                      |    |

<code>
author:
<em>
USERNAME
</em>
</code>
| 
**bootstrap in:body author:octocat** 匹配由 [](https://github.com/search?q=bootstrap+in%3Abody+author%3Aoctocat&type=Discussions) 创建且正文中含有“bootstrap”一词的讨论。 |

## 按评论者搜索

`commenter` 限定符查找含有特定用户评论的讨论。

| 限定符                                                                                                                                                                                                    | 示例 |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :- |
| <code>commenter:<em>USERNAME</em></code>                                                                                                                                                               |    |
| \[                                                                                                                                                                                                     |    |
| **github commenter:becca org:github**]\(<https://github.com/search?utf8=%E2%9C%93&q=github+commenter%3Abecca+org%3Agithub&type=Discussions>) 匹配属于 GitHub 组织的存储库中的讨论，这些讨论包含单词“github”，并且由 @becca 发表过评论。 |    |

## 按已回答讨论的用户进行搜索

`answered-by` 限定符会查找将某位用户的评论标记为答案的讨论。

| 限定符                                                                                                                                 | 示例 |
| :---------------------------------------------------------------------------------------------------------------------------------- | :- |
| <code>answered-by:<em>USERNAME</em></code>                                                                                          |    |
| \[                                                                                                                                  |    |
| **cool answered-by:octocat**]\(<https://github.com/search?q=cool+author%3Aoctocat&type=Discussions>) 匹配由 @octocat 回答且包含单词“cool”的讨论。 |    |

## 按涉及讨论的用户搜索

可使用 `involves` 限定符查找涉及特定用户的讨论。 该限定符返回由特定用户创建、提及该用户或包含该用户评论的讨论。
`involves` 限定符是 `author`、`mentions` 和 `commenter` 限定符之间的逻辑 OR，用于单个用户。

| 限定符                                                                                                                                                  | 示例 |
| :--------------------------------------------------------------------------------------------------------------------------------------------------- | :- |
| <code>involves:<em>USERNAME</em></code>                                                                                                              |    |
| \*\*                                                                                                                                                 |    |
| [involves:becca involves:octocat](https://github.com/search?q=involves%3Abecca+involves%3Aoctocat\&type=Discussions)\*\* 匹配 @becca 或 @octocat 参与的讨论。 |    |
| `in:body`                                                                                                                                            |    |

<code>
involves:
<em>
USERNAME
</em>
</code>
| 
[
**NOT free in:body involves:becca**](https://github.com/search?q=NOT+free+in%3Abody+involves%3Abecca&type=Discussions) 匹配 @becca 参与且正文中不包含单词“free”的讨论。

## 按评论数量搜索

可使用 `comments` 限定符以及大于、小于和范围限定符以按评论数量搜索。 有关详细信息，请参阅“[了解搜索语法](/zh/enterprise-server@3.22/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax)”。

| 限定符                                                                                                     | 示例 |
| :------------------------------------------------------------------------------------------------------ | :- |
| <code>comments:<em>n</em></code>                                                                        |    |
| \[                                                                                                      |    |
| **comments:>100**]\(<https://github.com/search?q=comments%3A%3E100&type=Discussions>) 匹配评论数超过 100 条的讨论。 |    |
| <code>comments:<em>n</em></code>                                                                        |    |
| **comments:500..1000** 匹配包含 500 到 1000 条评论的讨论。                                                          |    |

## 按讨论创建或上次更新时间搜索

您可以基于创建时间或上次更新时间过滤讨论。 对于讨论创建，可使用 `created` 限定符；要了解讨论上次更新的时间，请使用 `updated` 限定符。

两个限定符都使用日期作为参数。 日期格式必须遵循 [ISO8601](http://en.wikipedia.org/wiki/ISO_8601) 标准，即 `YYYY-MM-DD`（年-月-日）。 也可以在日期后添加可选的时间信息 `THH:MM:SS+00:00`，以按小时、分钟和秒进行搜索。 即 `T`，随后是 `HH:MM:SS`（时-分-秒）和 UTC 时差 (`+00:00`)。

搜索日期时，可以使用大于、小于和范围限定符来进一步筛选结果。 有关详细信息，请参阅“[了解搜索语法](/zh/enterprise-server@3.22/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax)”。

| 限定符                                                                                                                                                                        | 示例 |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :- |
| <code>created:<em>YYYY-MM-DD</em></code>                                                                                                                                   |    |
| **created:>2020-11-15** 匹配在 2020 年 11 月 15 日之后创建的讨论。                                                                                                                       |    |
| <code>updated:<em>YYYY-MM-DD</em></code>                                                                                                                                   |    |
| \[                                                                                                                                                                         |    |
| **weird in:body updated:>=2020-02-01**]\(<https://github.com/search?q=weird+in%3Abody+updated%3A%3E%3D2020-12-01&type=Discussions>) 匹配正文中包含单词“weird”且在 2020 年 12 月之后更新的讨论。 |    |

## 按类别搜索

可以按特定讨论类别来筛选讨论。

| 限定符                                         | 示例 |
| :------------------------------------------ | :- |
| <code>category:<em>CATEGORYNAME</em></code> |    |
| **category:Ideas** 匹配与名称“Ideas”匹配的讨论类别。     |    |

## 按标签搜索

可以按应用于讨论的特定标签来筛选讨论。

| 限定符    | 示例 |
| :----- | :- |
| <code> |    |
| label: |    |

<em>
"LABEL NAME"
</em>
</code>
| 
**label:"Product Feedback"** 匹配与标签“Product Feedback”匹配的讨论。

## 其他阅读材料

* [排序搜索结果](/zh/enterprise-server@3.22/search-github/getting-started-with-searching-on-github/sorting-search-results)