# 搜索是否应限制在类别内，并包含子类别？

**URL:** <https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100>\
**Category:** Feature\
**Created:** [2016年三月15日 18:12 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100 "2016-03-15T18:12:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2016年三月15日 18:12 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/1 "2016-03-15T18:12:01Z")

</div>

我有一个用于挑战/任务的分类，除了其子分类外，该分类本身是空的。我原以为搜索该分类就能找到子分类中的内容，但实际却不行。

在这里的 meta 页面上，点击 #Customization > Plugin 并搜索 “discord”，你可以找到 “Discourse to Discord bot” 这篇帖子；但如果直接搜索该插件分类，这条帖子就找不到了。如果能在所有这些分类中一起搜索就好了。

 ![](https://global.discourse-cdn.com/meta/original/3X/3/5/3588c7422c084d2ff208aa1e5bb4b20228d985e9.png)

 ![](https://global.discourse-cdn.com/meta/original/3X/1/7/176ef7e1ac91a3e37f6bfc6e8c6e726e4da48fbd.png)

---

<div class="post-metadata">

**Author:** ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)\
**Post date:** [2016年三月16日 20:53 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/2 "2016-03-16T20:53:24Z")

</div>

Hmm yeh, haven’t really encountered this before but I think searching category+sub-categories by default makes sense. We’d have to come up with some sort of syntax for when you only want to search the parent category though, like `category:plugin+none`

---

<div class="post-metadata">

**Author:** ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)\
**Post date:** [2017年二月7日 22:00 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/3 "2017-02-07T22:00:20Z")

</div>

This is now supported as per this change by @sam

[https://github.com/discourse/discourse/commit/df8f365d999e113615c51efee4cfa3115c267783](https://github.com/discourse/discourse/commit/df8f365d999e113615c51efee4cfa3115c267783)

So:

To search #howto and all sub categories use

> something #howto

OR

> something category:howto

To restrict it so you only search the category #howto without children use:

> something #=howto

OR

> something category:=howto

* * *

We still need to decide what to do about the “search this category” checkbox.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2017年二月8日 02:10 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/4 "2017-02-08T02:10:40Z")

</div>

> [@erlend\_sh](#):
>
> We still need to decide what to do about the “search this category” checkbox

Is there room for two check boxes?

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2017年二月8日 02:17 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/5 "2017-02-08T02:17:43Z")

</div>

When is two checkboxes ever the right choice?

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2017年二月8日 02:24 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/6 "2017-02-08T02:24:41Z")

</div>

Sounds compelling. In that case, I vote for the check box to include subcategories.

---

<div class="post-metadata">

**Author:** ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)\
**Post date:** [2017年二月8日 11:11 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/7 "2017-02-08T11:11:28Z")

</div>

> [@pfaffman](#):
>
> In that case, I vote for the check box to include subcategories.

You mean to exclude? As it is included by default now…

---

<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:** [2017年二月8日 14:22 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/8 "2017-02-08T14:22:59Z")

</div>

> [@cpradio](#):
>
> You mean to exclude? As it is included by default now…

I think he means this 🙂

 ![](https://global.discourse-cdn.com/meta/original/3X/1/0/106bdd981bf8b72902ca3f6fa83f0d3a423996b5.png)

 ![](https://global.discourse-cdn.com/meta/original/3X/3/b/3be4d8d284fffa9ff2b996e5317908fca189caba.png)

I also think include by default is probably a better call

“Search the #howto category” may need slightly better wording though.

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2017年二月23日 02:47 UTC](https://meta.discourse.org/t/should-search-limited-to-category-also-search-subcategories/41100/9 "2017-02-23T02:47:19Z")

</div>


