# Returning the child fields next to matched field

**URL:** https://discuss.elastic.co/t/returning-the-child-fields-next-to-matched-field/264077
**Category:** Elasticsearch
**Created:** [February 12, 2021, 3:10am UTC](https://discuss.elastic.co/t/returning-the-child-fields-next-to-matched-field/264077 "2021-02-12T03:10:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jaripog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaripog/32/83813_2.png) [@jaripog](https://discuss.elastic.co/u/jaripog)
#### Post date: [February 12, 2021, 3:10am UTC](https://discuss.elastic.co/t/returning-the-child-fields-next-to-matched-field/264077/1 "2021-02-12T03:10:38Z")

</div>

Assume that I have a document like below

{  
"\_index": "sample",  
"\_type": "doc",  
"\_id": "student\_id\_1",  
"\_version":2,  
"\_score":1,  
"\_source":  
{  
"title": "Higher secondary",  
"DOJ":2020-06-23,  
"S\_id":"SH123",  
"first\_name":"Gopiraj",  
"last\_name":"Muthusamy"  
"subjects":[  
{  
"name":"english"  
"type":"communication"  
"sub\_id":1  
},{  
"name":"Maths"  
"type":"learning"  
"sub\_id":2  
},{  
"name":"science"  
"type":"learning"  
"sub\_id":3  
}]  
}  
}

from the above document i using highlight method to display the macthed field and its value but its not returning other fields inside the hash, for example the word that i need to search for is "learning", I'm expecting ES should return like below in highlight or in any other form

[  
{  
"sub\_id":2,  
"type":"learning"  
},{  
"sub\_id":3,  
"type":"learning"  
}  
]

Please guide

---

<div class="post-metadata">

### Author: ![jaripog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaripog/32/83813_2.png) [@jaripog](https://discuss.elastic.co/u/jaripog)
#### Post date: [February 15, 2021, 6:46am UTC](https://discuss.elastic.co/t/returning-the-child-fields-next-to-matched-field/264077/2 "2021-02-15T06:46:40Z")

</div>

does highlight\_query inside highlight will work? I know that highlight\_query is used to work on the resultant data but still is there is any chance of getting the results expected above?

---

<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: [March 15, 2021, 6:46am UTC](https://discuss.elastic.co/t/returning-the-child-fields-next-to-matched-field/264077/3 "2021-03-15T06:46:55Z")

</div>

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