# Searching with quoted term doesn't highlight the whole term

**URL:** https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954
**Category:** Bug
**Created:** [August 10, 2015, 2:00pm UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954 "2015-08-10T14:00:56Z")
**Posts on this page:** 10
**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: [August 10, 2015, 2:00pm UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/1 "2015-08-10T14:00:56Z")

</div>

Continuing the discussion from [The term "ost.io" creates trouble for search](https://meta.discourse.org/t/the-term-ost-io-creates-trouble-for-search/30982/13):

![](https://global.discourse-cdn.com/meta/original/3X/6/1/61545bda11ddb755e918c9332d4589b03cc95646.png)

I’d expect it to highlight the whole term, but it highlights just arbitrary words.

 ![](https://global.discourse-cdn.com/meta/original/3X/4/d/4de96740ec5c7648257a9341c94dba398b6ea202.png)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [August 10, 2015, 2:10pm UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/2 "2015-08-10T14:10:40Z")

</div>

You don’t need the quotes for an exact term match 😉

![](https://global.discourse-cdn.com/meta/original/3X/4/2/42e325dc6f5c325e5a3c24f2701674c72330deee.png)

* * *

![](https://global.discourse-cdn.com/meta/original/3X/2/a/2a116ea780728cf8c398fd9e166aeae47c427db2.png)

---

<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: [August 11, 2015, 2:00am UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/3 "2015-08-11T02:00:37Z")

</div>

If this is an easy fix we should fix it @sam

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [August 13, 2015, 4:51pm UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/4 "2015-08-13T16:51:26Z")

</div>

Looks to me like the highlighter just needs to strip out the quotes.

---

<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: [September 23, 2015, 12:51pm UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/5 "2015-09-23T12:51:41Z")

</div>

It’s still not highlighting the quoted term and now it shows double quotes for the search term.

 ![](https://global.discourse-cdn.com/meta/original/3X/2/2/2281cad8f64648ebeb629757146867f902d8aa66.png)

---

<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: [October 12, 2015, 1:22am UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/6 "2015-10-12T01:22:58Z")

</div>

I want to get to fixing this but its a fairly involved fixed, the highlighter needs to understand this behavior, it only highlights words now not full terms.

---

<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: [July 20, 2017, 1:39am UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/7 "2017-07-20T01:39:18Z")

</div>

I really, _really_ want this fixed, it is pretty disastrous from a UI perspective, also I’m not even sure it’s searching for a full quoted phrase in this scenario?

---

<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: [July 20, 2017, 9:00pm UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/8 "2017-07-20T21:00:44Z")

</div>

Done per:

 ![](https://global.discourse-cdn.com/meta/original/3X/e/f/ef1635d6578b22f4847899d456f4c304f64bc6d5.png)

per:

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

I changed it so we only match whole words, centralized the highlighting code and deal with exact terms.

---

<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: [July 20, 2017, 9:03pm UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/9 "2017-07-20T21:03:26Z")

</div>

One interesting edge case here is that the `really` being in italics in your post breaks the algorithm.

Cause we match the index and then try to match raw, we are going to have to change it to try to do the exact match on a normalized text only version of the post.

---

<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: [June 12, 2018, 8:25am UTC](https://meta.discourse.org/t/searching-with-quoted-term-doesnt-highlight-the-whole-term/31954/10 "2018-06-12T08:25:03Z")

</div>


