# Can we get required fields from source using innerhits of nested object

**URL:** <https://discuss.elastic.co/t/can-we-get-required-fields-from-source-using-innerhits-of-nested-object/165196>\
**Category:** Elasticsearch\
**Created:** [January 22, 2019, 9:07am UTC](https://discuss.elastic.co/t/can-we-get-required-fields-from-source-using-innerhits-of-nested-object/165196 "2019-01-22T09:07:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasad.ram1431](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@prasad.ram1431](https://discuss.elastic.co/u/prasad.ram1431)\
**Post date:** [January 22, 2019, 9:07am UTC](https://discuss.elastic.co/t/can-we-get-required-fields-from-source-using-innerhits-of-nested-object/165196/1 "2019-01-22T09:07:45Z")

</div>

Hi All,

I wanted to know whether we can get selected fields using innerhits from nested object like,  
{  
"query": {  
"nested": {  
"path": "",  
"query": {  
"range": {  
"toDate": {  
"gte": "2015-01-01",  
"lte": "2016-12-31"  
}  
}  
},  
"inner\_hits": {  
"\_source": ["fromDate"],  
"highlight": {  
"fields": {  
"toDate": {}  
}  
}  
}  
}  
}  
}

Please let me know above innerhits query will work, I want to retrieve only selected fields inside the innerhits response.

Thanks,  
Ram

---

<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:** [February 19, 2019, 9:07am UTC](https://discuss.elastic.co/t/can-we-get-required-fields-from-source-using-innerhits-of-nested-object/165196/2 "2019-02-19T09:07:46Z")

</div>

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