# 2.3 での検索機能の改善

**URL:** https://meta.discourse.org/t/search-improvements-in-2-3/113411
**Category:** Announcements
**Tags:** new-feature
**Created:** [2019 年 4 月 4 日午前 4:23 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411 "2019-04-04T04:23:32Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2019 年 4 月 4 日午前 4:23 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/1 "2019-04-04T04:23:32Z")

</div>

For the upcoming 2.3 release, we’ve added a new feature and made several fixes to the way we index posts for search that will make search results better.

### 1. Search Priorities for Categories

 ![Screenshot%20from%202019-04-04%2011-20-00](https://global.discourse-cdn.com/meta/original/3X/f/0/f0cd52f76c30f501f8af74f311b5fd303603d5fd.png)  
Each individual category can be configured with a search priority which you can find under the `Settings` tab when creating/editing a category. Five levels for prioritization have been added: `ignore`, `very low`, `low`, `high` and `very high`. The levels work by multiplying a pre-configured weight to the search ranking for each result and can be configured via hidden site settings in your console.

> <https://github.com/discourse/discourse/blob/588f61f717d59d0ac2030f290b98145a7a5956d1/config/site_settings.yml#L1618-L1633>

As an example, configuring a category’s search priority to `very_high` will boost its search ranking by 40% while a search priority of `very_low` will reduce its search ranking by 40%. Setting a category’s search priority to `ignore` will remove it from the search results. However, you can still search for posts within the ignored category by scoping the search to the category via advanced search. Do take note that search priority is not inherited which means that a sub-category will still be searchable even if the parent category has been configured to be ignored.

### 2. Improvements and Fixes to Search Results

1. Search relevance has been updated to consider the document length in the ranking. Previously, search ranking was ranked by the most number of matches for the given search term. This was problematic for search results as we noticed that longer posts were more likely to be ranked higher because of the tendency to produce a higher number of matches. As a result, we’ve made the switch to consider the document length when ranking search results.  
[FIX: Relevance search will now consider document length in ranking. · discourse/discourse@e87ca59 · GitHub](https://github.com/discourse/discourse/commit/e87ca594014733d171df0112149f49180d898678)

2. Improve the quality of the raw data that we use to generate the search index. [PERF: Improve quality of `PostSearchData#raw_data`. (#7275) · discourse/discourse@cfd5078 · GitHub](https://github.com/discourse/discourse/commit/cfd507822f9330967f3ed9f970505e7f4896b523)

3. Empty posts such as moderator actions or small post actions (closing, assigning) are no longer part of the search index. This change leads to a smaller index and less noise in search results. [FIX: Don't index posts with empty `Post#raw` for search. (#7263) · discourse/discourse@daeda80 · GitHub](https://github.com/discourse/discourse/commit/daeda80ada1d914d52dcc53a2cda087e5f62330c)

4. Smaller search index by deleting posts of trashed topics from the index. [PERF: Delete search data of posts from trashed topics periodically. (… · discourse/discourse@d151425 · GitHub](https://github.com/discourse/discourse/commit/d151425353cb4a99ee9cc543ed75925d9c3edc17)

5. When a post is moved to a different topic, the search data for the post was not updated and would lead to the post incorrectly appearing in searches that matched the category of the old topic. [FIX: Reindex post for search when post is moved to a different topic. · discourse/discourse@d808f36 · GitHub](https://github.com/discourse/discourse/commit/d808f36fc407a201b79755d9e48e7682e8407edd)

6. Smaller payload for search results by excluding the cooked version of the posts. [PERF: Reduce number of queries and size of payload when searching. · discourse/discourse@03c6b22 · GitHub](https://github.com/discourse/discourse/commit/03c6b22c626c6c91e009020e40817751d1421324)

7. The blurb for posts in search results was broken when searching for an exact phrase and lead to missing search term highlights on the client side. [FIX: Post blurb incorrect when search contains a phrase match. · discourse/discourse@dae0bb4 · GitHub](https://github.com/discourse/discourse/commit/dae0bb4c67c9f7f1eb475fb60f375118f93cdfd9)

Do let us know if you’re search results have improved after these changes. We would also like to know if you think your search results have become worse so that we can continue to refine it. Thank you all!

---

<div class="post-metadata">

### Author: ![dltj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dltj/32/114914_2.png) [@dltj](https://meta.discourse.org/u/dltj)
#### Post date: [2019 年 4 月 12 日午後 1:13 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/4 "2019-04-12T13:13:00Z")

</div>

Is the age of a post part of the weight in ranking search results? Information gets stale fairly quickly in our forum, so it would be nice to have a way to reduce the relevance of older postings without actually eliminating them.

---

<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: [2019 年 4 月 13 日午前 5:58 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/5 "2019-04-13T05:58:50Z")

</div>

Not yet, but it is an interesting idea, even in the weaker form of simply factoring in the date the topic was last touched

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [2019 年 10 月 26 日午前 8:38 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/6 "2019-10-26T08:38:28Z")

</div>

検索結果でトピックを「ピン留め」して、常に最上位に表示されるようにする方法があると嬉しいです。そうすれば、よくある検索で直接チュートリアルへ誘導できます。

---

<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: [2019 年 10 月 26 日午前 10:25 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/7 "2019-10-26T10:25:50Z")

</div>

これを行うには、そのトピックが属するカテゴリの検索優先順位を変更します。

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [2019 年 10 月 26 日午前 10:27 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/8 "2019-10-26T10:27:02Z")

</div>

私の「問題」は、それらのトピックが文脈に基づいてすべてのフォーラムカテゴリに散らばっていることです。したがって、カテゴリベースのアプローチは使えません。

---

<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: [2019 年 10 月 26 日午前 10:28 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/9 "2019-10-26T10:28:55Z")

</div>

そうすると、この問題はトピックごとにランダムに行う方法が存在しないため、これからも決して解決できません。

---

<div class="post-metadata">

### Author: ![ssvenn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ssvenn/32/86740_2.png) [@ssvenn](https://meta.discourse.org/u/ssvenn)
#### Post date: [2019 年 10 月 26 日午前 10:44 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/10 "2019-10-26T10:44:04Z")

</div>

もしかして、いずれはタグの検索優先順位を設定できるようにするかもしれませんね。ただし、トピックに複数のタグが付けられる可能性があるため、それほど単純ではないかもしれません。

いずれにせよ、カテゴリに重み付けできる機能は素晴らしいですね！私のフォーラムにはいくつかのスパム的な特殊用途カテゴリがあり、検索結果で少し下に押しやれると嬉しいです。

---

<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: [2019 年 10 月 28 日午前 6:50 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/11 "2019-10-28T06:50:23Z")

</div>

> [@ssvenn](#):
>
> もしかして、いずれタグの検索優先順位という機能ができるかもしれませんね？

はい、いつかそうなると思います。

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [2019 年 10 月 28 日午前 7:25 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/12 "2019-10-28T07:25:59Z")

</div>

それは素晴らしいですね！そうすれば、ブログ投稿をそのようにタグ付けし、検索で優先的に表示させることができます。

---

<div class="post-metadata">

### Author: ![Perry\_Eising](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/perry_eising/32/151717_2.png) [@Perry\_Eising](https://meta.discourse.org/u/Perry_Eising)
#### Post date: [2019 年 11 月 13 日午後 10:54 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/13 "2019-11-13T22:54:22Z")

</div>

特定のタグが検索の優先順位にも影響を与える方法があれば、ぜひ見てみたいです。

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [2020 年 4 月 4 日午前 10:19 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/14 "2020-04-04T10:19:48Z")

</div>

2.4.X または 2.5 にこれを追加する予定はありますか？

---

<div class="post-metadata">

### Author: ![michellefs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michellefs/32/234543_2.png) [@michellefs](https://meta.discourse.org/u/michellefs)
#### Post date: [2022 年 1 月 5 日午後 9:09 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/15 "2022-01-05T21:09:55Z")

</div>

これはもう一般的なことですか？

このリソースを解読するには、私は十分な知識がありません。検索コントローラー [Need help with understanding how discourse search works - #3 by neounix](https://meta.discourse.org/t/need-help-with-understanding-how-discourse-search-works/173342/3?u=michellefs)

---

<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: [2022 年 1 月 5 日午後 9:15 UTC](https://meta.discourse.org/t/search-improvements-in-2-3/113411/17 "2022-01-05T21:15:55Z")

</div>

> [@michellefs](#):
>
> > [@sam](#):
> >
> > > [@ssvenn](#):
> > >
> > > タグの検索優先順位も、将来的には実装されるかもしれませんか？
> > 
> > はい、いずれはそうなると思います。
> 
> これは現在実装されていますか？

まだです。現時点では、カテゴリのみ検索優先順位を設定できます。
