# No highlights with function\_score query

**URL:** <https://discuss.elastic.co/t/no-highlights-with-function-score-query/14823>\
**Category:** Elasticsearch\
**Created:** [December 11, 2013, 9:40pm UTC](https://discuss.elastic.co/t/no-highlights-with-function-score-query/14823 "2013-12-11T21:40:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)\
**Post date:** [December 11, 2013, 9:40pm UTC](https://discuss.elastic.co/t/no-highlights-with-function-score-query/14823/1 "2013-12-11T21:40:25Z")

</div>

The ES is not returning highlights for the given function\_score query below on Elasticsearch 0.90.7

{  
"facets": {  
"histo": {  
"date\_histogram": {  
"field": "closeDt",  
"interval": "1h"  
}  
},  
"channel": {  
"terms": {  
"field": "channel"  
}  
},  
"siteId": {  
"terms": {  
"field": "siteId"  
}  
},  
"domains.L1.domain.id": {  
"terms": {  
"field": "domains.L1.domain.id"  
}  
}  
},  
"query": {  
"query\_string": {  
"query": "payment",  
"default\_operator": "AND",  
"fields": [  
[  
"emails.emailBody",  
"srId",  
"chatTextArray.text"  
]  
]  
},  
"filtered": {  
"filter": {  
"and": [  
{  
"term": {  
"domains.L1.domain.id": "2"  
}  
},  
{  
"range": {  
"closeDt": {  
"from": 1325404800000,  
"to": 1386835200000  
}  
}  
}  
]  
}  
},  
"function\_score": {  
"functions": [  
{  
"script\_score": {  
"script": "\_score\*\_source.\_boost\*doc['domains.L1.domain.2.prob'].value"  
}  
}  
]  
}  
},  
"highlight": {  
"pre\_tags": [  
""  
],  
"post\_tags": [  
""  
],  
"fields": {  
"srId": {  
"number\_of\_fragments": 0  
},  
"emails.emailBody": {  
"number\_of\_fragments": 0  
},  
"chatTextArray.text": {  
"number\_of\_fragments": 0  
}  
}  
}  
}

i was expecting to receive highlights with the results.

thanks for your help!

---

<div class="post-metadata">

**Author:** ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)\
**Post date:** [December 11, 2013, 11:14pm UTC](https://discuss.elastic.co/t/no-highlights-with-function-score-query/14823/2 "2013-12-11T23:14:05Z")

</div>

I tried with the following query it returns highlights, but term filter is not working.  
On the other hand if i use {filtered:filter..} it applies the term filter correctly, but doesn't return the highlighted results.

{  
"facets": {  
"histo": {  
"date\_histogram": {  
"field": "closeDt",  
"interval": "1h"  
}  
},  
"channel": {  
"terms": {  
"field": "channel"  
}  
},  
"siteId": {  
"terms": {  
"field": "siteId"  
}  
},  
"domains.L1.domain.id": {  
"terms": {  
"field": "domains.L1.domain.id"  
}  
}  
},  
"query": {  
"function\_score": {  
"query": {  
"query\_string": {  
"query": "payment",  
"default\_operator": "AND",  
"fields": [  
[  
"emails.emailBody",  
"srId",  
"chatTextArray.text"  
]  
]  
}  
},  
"functions": [  
{  
"filter": {  
"and": [  
{  
"term": {  
"domains.L1.domain.id": "2"  
}  
},  
{  
"range": {  
"closeDt": {  
"from": 1325404800000,  
"to": 1386835200000  
}  
}  
}  
]  
},  
"script\_score": {  
"script": "\_score\*\_source.\_boost\*doc['domains.L1.domain.2.prob'].value"  
}  
}  
]  
}  
},  
"highlight": {  
"pre\_tags": [  
""  
],  
"post\_tags": [  
""  
],  
"fields": {  
"srId": {  
"number\_of\_fragments": 0  
},  
"emails.emailBody": {  
"number\_of\_fragments": 0  
},  
"chatTextArray.text": {  
"number\_of\_fragments": 0  
}  
}  
},  
"timeout": 30000  
}

---

<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 6, 2017, 2:01am UTC](https://discuss.elastic.co/t/no-highlights-with-function-score-query/14823/3 "2017-07-06T02:01:52Z")

</div>


