# Highlight filter queries

**URL:** <https://discuss.elastic.co/t/highlight-filter-queries/13297>\
**Category:** Elasticsearch\
**Created:** [August 22, 2013, 12:41pm UTC](https://discuss.elastic.co/t/highlight-filter-queries/13297 "2013-08-22T12:41:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishna20](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@krishna20](https://discuss.elastic.co/u/krishna20)\
**Post date:** [August 22, 2013, 12:41pm UTC](https://discuss.elastic.co/t/highlight-filter-queries/13297/1 "2013-08-22T12:41:29Z")

</div>

Highlight works for the following query. But, i want to highlight the query values present in the filter too. Do i need to entirely change my query structure for that or am i missing out anything in this??

curl "10.237.247.16:9200/cai/\_search?pretty=true" -d '{  
"query": {  
"filtered": {  
"query": {  
"field": {  
"complete": "_PATIENT\_MERG\_2_"  
}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"query": {  
"wildcard": {  
"unanalyzedtrace": "_23:01:7_"  
}  
}  
},  
{  
"query": {  
"wildcard": {  
"unanalyzedtrace": "_ICP.IR1.MANUALMERGE.IN_"  
}  
}  
}  
]  
}  
}  
}  
},  
"highlight": {  
"fields": {  
"complete": {},  
"unanalyzedtrace":{}  
}  
}  
}'

**RESPONSE**

{  
"took" : 90,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "cai",  
"\_type" : "walgreens",  
"\_id" : "95f17940-db3b-11e2-bb79-68b5996e3bea",  
"\_score" : 1.0, "\_source" : {"StartDt":"2013-05-01 23:01:7","GroupId":"PATIENT\_MERG\_2","QueueName":"ICP.IR1.MANUALMERGE.IN","longtime":1367429467000,"estime":"2013-05-01T23:01:07","timeOrginal":"2013-05-01 23:01:7","complete":"2013-05-01 23:01:7,300,PATIENT\_MERG\_2,ICP.IR1.MANUALMERGE.IN,0,0,0,0,0,-1,-1,0,-1,-1,0,-1,-1,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0","unanalyzedtrace":"2013-05-01 23:01:7,300,PATIENT\_MERG\_2,ICP.IR1.MANUALMERGE.IN,0,0,0,0,0,-1,-1,0,-1,-1,0,-1,-1,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0"},  
"highlight" : {  
"complete" : ["2013-05-01 23:01:7,300,_PATIENT\_MERG\_2_,ICP.IR1.MANUALMERGE.IN,0,0,0,0,0,-1,-1,0,-1,-1,0,-1,-1,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0"]  
}  
} ]  
}  
}

**When tried to change query to work on 'unanalyzedtrace' instead of 'complete', the whole value gets highlighted.**

**New Request**

* * *

## "query": { "wildcard": { "unanalyzedtrace": "_PATIENT\_MERG\_2_" } },

**Response**

{  
"took" : 66,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "cai",  
"\_type" : "walgreens",  
"\_id" : "95f17940-db3b-11e2-bb79-68b5996e3bea",  
"\_score" : 1.0, "\_source" : {"StartDt":"2013-05-01 23:01:7","GroupId":"PATIENT\_MERG\_2","QueueName":"ICP.IR1.MANUALMERGE.IN","longtime":1367429467000,"estime":"2013-05-01T23:01:07","timeOrginal":"2013-05-01 23:01:7","complete":"2013-05-01 23:01:7,300,PATIENT\_MERG\_2,ICP.IR1.MANUALMERGE.IN,0,0,0,0,0,-1,-1,0,-1,-1,0,-1,-1,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0","unanalyzedtrace":"2013-05-01 23:01:7,300,PATIENT\_MERG\_2,ICP.IR1.MANUALMERGE.IN,0,0,0,0,0,-1,-1,0,-1,-1,0,-1,-1,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0"},  
"highlight" : {  
"unanalyzedtrace" : ["_2013-05-01 23:01:7,300,PATIENT\_MERG\_2,ICP.IR1.MANUALMERGE.IN,0,0,0,0,0,-1,-1,0,-1,-1,0,-1,-1,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0_"]  
}  
} ]  
}  
}

---

<div class="post-metadata">

**Author:** ![es\_yong](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@es\_yong](https://discuss.elastic.co/u/es_yong)\
**Post date:** [July 15, 2016, 2:59am UTC](https://discuss.elastic.co/t/highlight-filter-queries/13297/2 "2016-07-15T02:59:59Z")

</div>

you need use "inner hits" to highlight the content. for example:  
"inner\_hits": {  
"highlight": {  
"fields": {  
"details":{  
"type": "plain",  
"force\_source" : true,  
"fragment\_size": 20,  
"number\_of\_fragments": 3  
}  
}  
},  
"size":1,  
"sort": { "praiseCount": "desc"}  
}

---

<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:35pm UTC](https://discuss.elastic.co/t/highlight-filter-queries/13297/3 "2017-07-05T22:35:22Z")

</div>


