# Highlight with Bool + filter Query

**URL:** <https://discuss.elastic.co/t/highlight-with-bool-filter-query/63949>\
**Category:** Elasticsearch\
**Created:** [October 26, 2016, 12:32am UTC](https://discuss.elastic.co/t/highlight-with-bool-filter-query/63949 "2016-10-26T00:32:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivangshah](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@shivangshah](https://discuss.elastic.co/u/shivangshah)\
**Post date:** [October 26, 2016, 12:32am UTC](https://discuss.elastic.co/t/highlight-with-bool-filter-query/63949/1 "2016-10-26T00:32:35Z")

</div>

Hi,

I am having the exact same issue mentioned here: [Elasticsearch exclude bool “term” from getting highlighted](https://discuss.elastic.co/t/elasticsearch-exclude-bool-term-from-getting-highlighted/13258)

Except now, the Filtered Query is deprecated to using Bool Query and with Bool + Filter Query, this is still a problem. I would like to exclude fields from highlight that are "terms" filter and only highlight fields that match my "query\_string" Filter. Is this possible?

---

<div class="post-metadata">

**Author:** ![Cristiana\_Tiugan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cristiana_tiugan/32/93274_2.png) [@Cristiana\_Tiugan](https://discuss.elastic.co/u/Cristiana_Tiugan)\
**Post date:** [October 26, 2016, 9:56am UTC](https://discuss.elastic.co/t/highlight-with-bool-filter-query/63949/2 "2016-10-26T09:56:43Z")

</div>

Hey,  
Maybe use a highlight query?

> **[Request body search | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-highlighting)**

> [@shivangshah](#):
>
> red Query is depreca

---

<div class="post-metadata">

**Author:** ![shivangshah](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@shivangshah](https://discuss.elastic.co/u/shivangshah)\
**Post date:** [October 26, 2016, 4:46pm UTC](https://discuss.elastic.co/t/highlight-with-bool-filter-query/63949/3 "2016-10-26T16:46:21Z")

</div>

Hi Cristiana,

That actually did work (in a weird way if I may). Basically what I had to do was

{  
"from" : 0,  
"size" : 10,  
"query" : {  
"bool" : {  
"filter" : [ {  
"terms" : {  
"someId" : ["52302"]  
}  
}, {  
"terms" : {  
"someType" : ["customer"]  
}  
}, {  
"simple\_query\_string" : {  
"query" : "Suspendisse"  
}  
} ]  
}  
},  
"\_source" : {  
"includes" : ["id", "someId", "someType", "someCategory"],  
"excludes" : []  
},  
"highlight" : {  
"require\_field\_match" : false,  
"highlight\_query" : {  
"simple\_query\_string" : {  
"query" : "Suspendisse"  
}  
},  
"fields" : {  
"\*" : { }  
}  
}  
}

I have to put the exact same query\_string query in highlight\_query and that seemed to work. My question would be, does this impact performance in any way? I am not sure how highlight\_query works internally? Does it make another query based off of the query that was given to it ? Because if this adds an extra query to the call, and is indeed not as performant, the type-ahead search with highlight will be slow.

Thoughts?

---

<div class="post-metadata">

**Author:** ![Cristiana\_Tiugan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cristiana_tiugan/32/93274_2.png) [@Cristiana\_Tiugan](https://discuss.elastic.co/u/Cristiana_Tiugan)\
**Post date:** [October 26, 2016, 8:41pm UTC](https://discuss.elastic.co/t/highlight-with-bool-filter-query/63949/4 "2016-10-26T20:41:14Z")

</div>

I am currently using this method because I had has\_child query and I couldn't use highlighting without highlight\_query and my performance didn't change  
But, I don't have an exact response, so, my advice is to make some performance tests and/or wait for an opinion?

---

<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:** [July 5, 2017, 10:09pm UTC](https://discuss.elastic.co/t/highlight-with-bool-filter-query/63949/5 "2017-07-05T22:09:21Z")

</div>


