# How to return a id value of nested document together with the highlight fields

**URL:** https://discuss.elastic.co/t/how-to-return-a-id-value-of-nested-document-together-with-the-highlight-fields/147172
**Category:** Elasticsearch
**Created:** [September 4, 2018, 8:54am UTC](https://discuss.elastic.co/t/how-to-return-a-id-value-of-nested-document-together-with-the-highlight-fields/147172 "2018-09-04T08:54:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![reamerit](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@reamerit](https://discuss.elastic.co/u/reamerit)
#### Post date: [September 4, 2018, 8:54am UTC](https://discuss.elastic.co/t/how-to-return-a-id-value-of-nested-document-together-with-the-highlight-fields/147172/1 "2018-09-04T08:54:32Z")

</div>

Hi All:  
I have a requirement that I need know the id value of the highlighted nested document. For sample:

> {"mappings": {  
> "item": {  
> "properties": {  
> "all": {  
> "type": "text",  
> "analyzer":"standard",  
> "search\_analyzer":"whitespace"  
> },  
> "main\_doc": {  
> "type": "text",  
> "copy\_to": ["all"]  
> },  
> "child\_doc": {  
> "type": "nested",  
> "properties": {  
> "doc\_content": {  
> "type": "text",  
> "copy\_to": ["all"]  
> },  
> "doc\_id": {  
> "type": "text"  
> }  
> }  
> }  
> }  
> }  
> }  
> }

After that, we do search on the field "all" and highlight all fields(both main and child without match).  
While, the highlight field only return the field name and the highlighted fragment.  
My question is , is there a way to return the doc\_id value together with the highlight fields in pair. Or away, to get the doc\_id value based on the hightlighted field?

---

<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: [October 2, 2018, 8:56am UTC](https://discuss.elastic.co/t/how-to-return-a-id-value-of-nested-document-together-with-the-highlight-fields/147172/2 "2018-10-02T08:56:34Z")

</div>

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