# Highlight exact phrases/keywords

**URL:** <https://discuss.elastic.co/t/highlight-exact-phrases-keywords/295982>\
**Category:** Elasticsearch\
**Created:** [February 1, 2022, 6:40pm UTC](https://discuss.elastic.co/t/highlight-exact-phrases-keywords/295982 "2022-02-01T18:40:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fidel\_Perez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fidel_perez/32/78585_2.png) [@Fidel\_Perez](https://discuss.elastic.co/u/Fidel_Perez)\
**Post date:** [February 1, 2022, 6:40pm UTC](https://discuss.elastic.co/t/highlight-exact-phrases-keywords/295982/1 "2022-02-01T18:40:50Z")

</div>

hello everyone  
I want to highlight the query match but to be an exact match when words or phrases

```auto
{
  "body": {
    "highlight": {
      "fields": {
        "textContent": {
          "fragment_size": 150,
          "number_of_fragments": 10
        }
      },
      "fragmenter": "span",
      "post_tags": [
        "</em>"
      ],
      "pre_tags": [
        "<em class='highlight' >"
      ],
      "tags_schema": "styled"
    },
    "query": {
      "bool": {
        "filter": {
          "term": {
            "_id": "_uj-vugO/LKIC_CP_9_190607_50_TD.pdf-1643724161041914"
          }
        },
        "must": {
          "query_string": {
            "fields": [
              "textContent",
              "title"
            ],
            "query": "fire \"ground floor\" \"implementation plan\""
          }
        }
      }
    }
  },
  "filterPath": "hits",
  "index": "my-index"
}

```

this is the search term: fire "ground floor" "implementation plan"  
this is what I want"

- "ground floor" phrase highlighted
- "fire" word highlighted
- "implementation plan" ignored because the phrase doesn't exist

LEVEL LIGHTING & DRY **FIRE** LAYOUT  
180484-JHA-SKE-E106 - LEVEL 1 LIGHTING & DRY **FIRE** LAYOUT  
180484-JHA-SKE-E107 - ROOF LIGHTING & DRY **FIRE** LAYOUT  
180484-FLOOR SLAB PLAN  
S182476-S06.02-2 **GROUND FLOOR** WALKWAY SLAB PLAN

but this is what I'm getting

- fire highlighted (this is ok)
- floor highlighted ( this is not ok since it is alone and not in the phrase)
- plan highlighted ( this is not ok since the phrase with "implementation plan" don't match)

LEVEL LIGHTING & DRY **FIRE** LAYOUT  
180484-JHA-SKE-E106 - LEVEL 1 LIGHTING & DRY **FIRE** LAYOUT  
180484-JHA-SKE-E107 - ROOF LIGHTING & DRY **FIRE** LAYOUT  
180484- **FLOOR** SLAB **PLAN**  
S182476-S06.02-2 **GROUND FLOOR** WALKWAY SLAB **PLAN**

thanks in advance

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 1, 2022, 6:41pm UTC](https://discuss.elastic.co/t/highlight-exact-phrases-keywords/295982/2 "2022-03-01T18:41:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
