# Combining Rescore Query with Highlight Query

**URL:** <https://discuss.elastic.co/t/combining-rescore-query-with-highlight-query/140025>\
**Category:** Elasticsearch\
**Created:** [July 14, 2018, 11:10am UTC](https://discuss.elastic.co/t/combining-rescore-query-with-highlight-query/140025 "2018-07-14T11:10:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saiprasad\_Krishnamur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saiprasad_krishnamur/32/32290_2.png) [@Saiprasad\_Krishnamur](https://discuss.elastic.co/u/Saiprasad_Krishnamur)\
**Post date:** [July 14, 2018, 11:10am UTC](https://discuss.elastic.co/t/combining-rescore-query-with-highlight-query/140025/1 "2018-07-14T11:10:12Z")

</div>

I'm trying to apply Highlight Query and want to give more score to the number of fields highlighted by the highlight query than the term frequency on a field.

For example:  
DOC 1:  
{  
"first\_name": "John"  
"last\_name": "Smith"  
"full\_name": "John Smith"  
}

```
DOC 2:    
{
"first_name": "John"
"last_name": "Stokes"      
"full_name": "John Smith John Smith"
    }

```

When I search using the full\_name field, I want DOC1 should be the first match. This is my query.  
{  
"query": {  
"query\_string": {  
"query": "John Smith",  
"fields": [  
"full\_name"  
],  
"use\_dis\_max": true,  
"tie\_breaker": 0,  
"default\_operator": "or",  
"auto\_generate\_phrase\_queries": false,  
"max\_determinized\_states": 10000,  
"enable\_position\_increments": true,  
"fuzziness": "AUTO",  
"fuzzy\_prefix\_length": 0,  
"fuzzy\_max\_expansions": 50,  
"phrase\_slop": 0,  
"escape": false,  
"split\_on\_whitespace": true,  
"boost": 1  
}  
},  
"rescore": {  
"window\_size": 50,  
"query": {  
"score\_mode": "multiply",  
"rescore\_query": {  
"function\_score": {  
"script\_score": {  
"script": {  
"source": "1"  
}  
}  
}  
},  
"rescore\_query\_weight": 10  
}  
},  
"highlight": {  
"pre\_tags": [  
"_"  
],  
"post\_tags": [  
"_"  
],  
"highlight\_query": {  
"query\_string": {  
"query": "John Smith",  
"fields": [  
"full\_name"  
],  
"use\_dis\_max": true,  
"tie\_breaker": 0,  
"default\_operator": "or",  
"auto\_generate\_phrase\_queries": false,  
"max\_determinized\_states": 10000,  
"enable\_position\_increments": true,  
"fuzziness": "AUTO",  
"fuzzy\_prefix\_length": 0,  
"fuzzy\_max\_expansions": 50,  
"phrase\_slop": 0,  
"escape": false,  
"split\_on\_whitespace": true,  
"boost": 1  
}  
},  
"require\_field\_match": false,  
"fields": {  
"\*": {  
"fragment\_size": 300,  
"number\_of\_fragments": 1  
}  
}  
}  
}

---

<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:** [August 11, 2018, 11:10am UTC](https://discuss.elastic.co/t/combining-rescore-query-with-highlight-query/140025/2 "2018-08-11T11:10:13Z")

</div>

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