# Elasticsearch search term highlighting

**URL:** <https://discuss.elastic.co/t/elasticsearch-search-term-highlighting/99700>\
**Category:** Elasticsearch\
**Created:** [September 7, 2017, 9:30am UTC](https://discuss.elastic.co/t/elasticsearch-search-term-highlighting/99700 "2017-09-07T09:30:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Narmatha](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@Narmatha](https://discuss.elastic.co/u/Narmatha)\
**Post date:** [September 7, 2017, 9:30am UTC](https://discuss.elastic.co/t/elasticsearch-search-term-highlighting/99700/1 "2017-09-07T09:30:36Z")

</div>

I need to highlight using primary(tag1) and secondary(tag2) tags for same field search. And the search terms would be like

term1 : [us, uk, use] term2: [rally, roster]

Tried with the below approach but it doesn't highlights the term1 results with primary tag and term2 results with secondary tag.

GET /test\*/\_search  
{  
"query": {  
"bool":{  
"should": [  
{  
"terms": {  
"atex.textContent": [  
"us", "uk", "use"  
]  
}},  
{"terms": {  
"atex.textContent": [  
"rally", "roster"  
]  
}  
}  
]  
}

```
     },
"highlight": {
  "pre_tags": ["<class = 'tag1'>",
"<class = 'tag2'>"],
"post_tags": ["</tag1>",
"</tag2>"],
  "fields": {
    "articleText.textContent": {
       "fragment_size" : 15000
    }
  }
}

```

}  
How to highlight the terms with correct highlighter ?

---

<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:** [October 5, 2017, 9:30am UTC](https://discuss.elastic.co/t/elasticsearch-search-term-highlighting/99700/2 "2017-10-05T09:30:56Z")

</div>

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