# Search only within topic titles

**URL:** https://meta.discourse.org/t/search-only-within-topic-titles/27600
**Category:** Feature
**Tags:** search
**Created:** [4월 15, 2015, 2:47오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600 "2015-04-15T14:47:15Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [4월 15, 2015, 2:47오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/1 "2015-04-15T14:47:15Z")

</div>

I’m often in the situation where I only want to search for topics that have certain words in their title.  
So, it would be great if there was a search modifier that allows me to search only within topic titles (something like `title:search text`).

---

<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: [4월 15, 2015, 10:39오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/2 "2015-04-15T22:39:54Z")

</div>

Keep in mind title matches are always prioritized. One issue I need to fix is that we are using the [snowball stemmer](http://snowball.tartarus.org/texts/introduction.html) which completely sucks compared to say ispell or something smarter, so it does a fair bit of messing with results.

Fine to add an advanced filter, but not sure it is needed cause we already show title matches first.

---

<div class="post-metadata">

### Author: ![nukeador](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nukeador/32/107477_2.png) [@nukeador](https://meta.discourse.org/u/nukeador)
#### Post date: [11월 2, 2017, 6:00오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/3 "2017-11-02T18:00:59Z")

</div>

My user case is that I need to find all topics with “Meeting” to add them a tag, searching on topics content will return me also false positives 😛

---

<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: [11월 2, 2017, 8:42오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/4 "2017-11-02T20:42:47Z")

</div>

Yeah I would like to have this. Anyone who is interested we can fund this work cc @cpradio who may have advice.

---

<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: [11월 6, 2017, 2:11오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/5 "2017-11-06T14:11:29Z")

</div>

I will take a stab at this, see if I can figure it out.

---

<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: [11월 6, 2017, 2:57오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/6 "2017-11-06T14:57:56Z")

</div>

Only advice I have is pay attention to the tokenizer, as I’m fairly certain that is something you’ll be utilizing.

---

<div class="post-metadata">

### Author: ![jorge\_manrubia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jorge_manrubia/32/108192_2.png) [@jorge\_manrubia](https://meta.discourse.org/u/jorge_manrubia)
#### Post date: [1월 25, 2018, 10:00오전 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/7 "2018-01-25T10:00:49Z")

</div>

Hey I’d like to work on this. Is that ok @pmusaraj? I wouldn’t like to overlap with your stuff if you have something in the works.

---

<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: [1월 25, 2018, 11:18오전 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/8 "2018-01-25T11:18:19Z")

</div>

You’re clear to work on this. @pmusaraj is working with us on other stuff.

---

<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: [1월 25, 2018, 12:12오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/9 "2018-01-25T12:12:52Z")

</div>

Yes, that would be great (I couldn’t figure this out).

---

<div class="post-metadata">

### Author: ![jorge\_manrubia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jorge_manrubia/32/108192_2.png) [@jorge\_manrubia](https://meta.discourse.org/u/jorge_manrubia)
#### Post date: [1월 27, 2018, 1:21오후 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/10 "2018-01-27T13:21:28Z")

</div>

Pull Request adding this:

> <https://github.com/discourse/discourse/pull/5538>
>
> It adds a new search option \`in:title\` that will make it search only in titles.
> …
> 
> It also adds a new checkbox at the top of the advanced search UI:
> 
> !\[screen recording 2018-01-27 at 02 01 pm\](https://user-images.githubusercontent.com/129938/35472184-a3760ad4-036a-11e8-846b-d01b83759e04.gif)
> 
> See: 
> 
> \- https://meta.discourse.org/t/add-in-title-modifier-to-advanced-search/38546?source\_topic\_id=77463
> \- https://meta.discourse.org/t/search-only-within-topic-titles/27600?source\_topic\_id=77463
> 
> \## Overview of changes
> 
> It changes the way posts and topics are indexed to use \[PostgreSQL full-text search weights\](https://www.postgresql.org/docs/9.1/static/textsearch-controls.html). Then, it uses the weight associated with \`title\` to filter by title when searching posts.
> 
> Before, it was concatenating \`title + body + category\` and storing the indexed result. Now, it will store the concatenation of weighted indexed parts.
> 
> This is my first experience with PostgreSQL full-text search. I think it is the proper way to do it after checking the docs. The weights system is a little bit bizarre with 4 values (A, B, C, D) but seems to work pretty well.
> 
> As a side effect, results will take weight into consideration when sorting. So \`title\` \> \`body\` \> \`category\`. From \[12.3.3. Ranking Search Results\](https://www.postgresql.org/docs/9.1/static/textsearch-controls.html):
> 
> \> If no weights are provided, then these defaults are used:
> \> {0.1, 0.2, 0.4, 1.0}
> 
> So for posts, weights will be 1.0 for title \`title\`, 0.4 for \`body\` and 0.2 for \`category\`. I think this is ok, but it's definitely something good to check before merging the PR. I tested this locally with a database with 19k posts from a forum I used to run, and the sorting made sense to me.
> 
> I will add some comments in the code to explain the changes next.
> 
> \## Reindexing required
> 
> \`in:title\` will only work after re-indexing all the posts. Not sure how to do it automatically when shipping this:
> 
> \- Should it trigger a reindexing job as part of the deploy? Is there support in place for such tasks? I guess we could launch a job from a migration if not
> \- Should it just increase \[the \`INDEX\_VERSION\` \](https://github.com/jorgemanrubia/discourse/blob/258051809096598a7390cfbdbac3191d4cf865e3/lib/search.rb#L4) and rely on the \[indexing job\](https://github.com/jorgemanrubia/discourse/blob/2c56f8df7c1eba7ff81bc66eaafd1e27a8c4ff19/app/jobs/scheduled/reindex\_search.rb#L3) that runs every day?
> 
> In development I have used \`rake search:reindex\` for testing this.

First time with PostgreSQL full text search so it would be great if someone with experience had a look 🙏.

---

<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: [2월 20, 2018, 4:39오전 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/11 "2018-02-20T04:39:35Z")

</div>

Per @jorge_manrubia this is now implemented. I pushed the change here:

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

Note: the UI is not updated yet, we are going to wait a few betas.

Keep in mind, this change will slowly appear on your forum after the update. We will update the search index for 20k posts every 2 hours to gain the new feature. If you feel like rushing it:

```plaintext
./launcher enter app
rake search:reindex

```

A rushed reindex is running on meta right 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: [2월 24, 2018, 7:00오전 UTC](https://meta.discourse.org/t/search-only-within-topic-titles/27600/12 "2018-02-24T07:00:15Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.
