# Parent-child highlighting

**URL:** <https://discuss.elastic.co/t/parent-child-highlighting/7698>\
**Category:** Elasticsearch\
**Created:** [May 15, 2012, 6:12am UTC](https://discuss.elastic.co/t/parent-child-highlighting/7698 "2012-05-15T06:12:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmz/32/2842_2.png) [@nmz](https://discuss.elastic.co/u/nmz)\
**Post date:** [May 15, 2012, 6:12am UTC](https://discuss.elastic.co/t/parent-child-highlighting/7698/1 "2012-05-15T06:12:50Z")

</div>

In a parent, child doc mapping, is it possible to highlight the  
matches in the child document?

---

<div class="post-metadata">

**Author:** ![nmz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmz/32/2842_2.png) [@nmz](https://discuss.elastic.co/u/nmz)\
**Post date:** [May 15, 2012, 10:10am UTC](https://discuss.elastic.co/t/parent-child-highlighting/7698/2 "2012-05-15T10:10:58Z")

</div>

I doubt it is an open issue : [[Feature request] Highlighting with parent/child queries · Issue #1764 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1764)

On May 15, 11:12 am, nmz [s.namith...@gmail.com](mailto:s.namith...@gmail.com) wrote:

> In a parent, child doc mapping, is it possible to highlight the  
> matches in the child document?

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [May 15, 2012, 2:47pm UTC](https://discuss.elastic.co/t/parent-child-highlighting/7698/3 "2012-05-15T14:47:24Z")

</div>

Its not possible as of now.  
You will have to do the task in 2 web calls.  
First one which runs the has\_children query. Here you need to collect the  
docid.  
Second web call should have \_parent with all the matching doc ID previously  
gathered

Thanks  
Vineeth

On Tue, May 15, 2012 at 3:40 PM, nmz [s.namitha.s@gmail.com](mailto:s.namitha.s@gmail.com) wrote:

> I doubt it is an open issue :  
> [[Feature request] Highlighting with parent/child queries · Issue #1764 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1764)
> 
> On May 15, 11:12 am, nmz [s.namith...@gmail.com](mailto:s.namith...@gmail.com) wrote:
> 
> > In a parent, child doc mapping, is it possible to highlight the  
> > matches in the child document?

---

<div class="post-metadata">

**Author:** ![Ulrik\_Pedersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ulrik_pedersen/32/11352_2.png) [@Ulrik\_Pedersen](https://discuss.elastic.co/u/Ulrik_Pedersen)\
**Post date:** [June 22, 2016, 9:23am UTC](https://discuss.elastic.co/t/parent-child-highlighting/7698/4 "2016-06-22T09:23:27Z")

</div>

In a should query I'm doing the following to highlight the children hits. However I'm experiencing som issues highlighting the hits from the parent at the same time - but hope this will solve your issues.

You can leave the filters - they are only for the purpose of fetching the active children in my setup.

"query": {  
"bool": {  
"should": [  
{  
"has\_child": {  
"type": "TYPE",  
"score\_mode": "max",  
"query": {  
"filtered": {  
"query": {  
"multi\_match": {  
"query": "QUERY",  
"fields": ["CHILD\_FIELD\_1", "CHILD\_FIELD\_2"]  
}  
},  
"filter": {  
"term": {  
"active": true  
}  
}  
}  
},  
"inner\_hits":{  
"highlight": {  
"fields": {  
"CHILD\_FIELD\_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:** [July 5, 2017, 10:41pm UTC](https://discuss.elastic.co/t/parent-child-highlighting/7698/5 "2017-07-05T22:41:26Z")

</div>


