# Fetching only matching fields from a nested field

**URL:** <https://discuss.elastic.co/t/fetching-only-matching-fields-from-a-nested-field/148825>\
**Category:** Elasticsearch\
**Created:** [September 17, 2018, 11:46am UTC](https://discuss.elastic.co/t/fetching-only-matching-fields-from-a-nested-field/148825 "2018-09-17T11:46:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohit1](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mohit1](https://discuss.elastic.co/u/mohit1)\
**Post date:** [September 17, 2018, 11:46am UTC](https://discuss.elastic.co/t/fetching-only-matching-fields-from-a-nested-field/148825/1 "2018-09-17T11:46:20Z")

</div>

Hi have a nested field with many fields and when i am querying it,it is returning all the fields even if it matches one, my query is as follows  
nested": {  
"path": "rooms",  
"query": {  
"bool": {  
"must": [  
{  
"range": {  
"rooms.single\_occupancy\_rate":{  
"lte" : budget  
}  
}  
},  
{  
"range": {  
"rooms.guest\_count": {  
"gte": 3  
}  
}  
}  
]  
}  
}  
}

please tell me how to retrieve only matching fields

---

<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 15, 2018, 11:57am UTC](https://discuss.elastic.co/t/fetching-only-matching-fields-from-a-nested-field/148825/2 "2018-10-15T11:57:31Z")

</div>

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