# How to merge SearchHitField and HighlightField

**URL:** <https://discuss.elastic.co/t/how-to-merge-searchhitfield-and-highlightfield/6038>\
**Category:** Elasticsearch\
**Created:** [December 1, 2011, 9:54am UTC](https://discuss.elastic.co/t/how-to-merge-searchhitfield-and-highlightfield/6038 "2011-12-01T09:54:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Weiwei\_Wang](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@Weiwei\_Wang](https://discuss.elastic.co/u/Weiwei_Wang)\
**Post date:** [December 1, 2011, 9:54am UTC](https://discuss.elastic.co/t/how-to-merge-searchhitfield-and-highlightfield/6038/1 "2011-12-01T09:54:03Z")

</div>

I noticed the search response seperate SearchHitField and  
HighlightField.

I have a field like "phone":  
[{"number":"18711341344","op":"ChinaMobile"},  
{"number":"139112314313","op":"ChinaMobile"}, when do highlighting for  
phone.number, the result return is something like that

{  
"took" : 7,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 0.29792547,  
"hits" : [ {  
"\_index" : "pim",  
"\_type" : "contact",  
"\_id" : "8a92e6e5335f724b013361dacd1225bd",  
"\_score" : 0.29792547,  
"fields" : {  
"id" : "8a92e6e5335f724b013361dacd1225bd",  
"phone" : [ {  
"op" : "China Mobile",  
"number" : "13681011893"  
}, {  
"op" : "China Mobile",  
"number" : "13681011893"  
}, {  
"op" : "China Mobile",  
"number" : "13681011893"  
} ],  
},  
"highlight" : {  
"phone.number" : [ "1368101189\<span class="hl"\>136810\</  
span\>3", "1368101189\<span class="hl"\>1368103",  
"1368101189\<span class="hl"\>1368103" ]  
}  
}]  
}  
}

so how to merge the result for use is a problem, what i would like is  
the SearchHitField already include the highlight result.

Besides, there is a bug for highlighter, if i set mapping for  
phone.number with "term\_vector":"with\_positions\_offsets", then the  
highlight result will concatenate the three numbers to only one  
highlighted string, which is also mentioned in

> <https://github.com/elastic/elasticsearch/issues/645>

when i changed the term\_vector to no, the highlighter works fine.

---

<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, 3:46am UTC](https://discuss.elastic.co/t/how-to-merge-searchhitfield-and-highlightfield/6038/2 "2017-07-06T03:46:47Z")

</div>

Closed on July 6, 2017, 3:46am UTC


