# How to get single record from nested type array

**URL:** <https://discuss.elastic.co/t/how-to-get-single-record-from-nested-type-array/228036>\
**Category:** Elasticsearch\
**Created:** [April 15, 2020, 6:04am UTC](https://discuss.elastic.co/t/how-to-get-single-record-from-nested-type-array/228036 "2020-04-15T06:04:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pankaj\_Jadhav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pankaj_jadhav/32/65896_2.png) [@Pankaj\_Jadhav](https://discuss.elastic.co/u/Pankaj_Jadhav)\
**Post date:** [April 15, 2020, 6:04am UTC](https://discuss.elastic.co/t/how-to-get-single-record-from-nested-type-array/228036/1 "2020-04-15T06:04:24Z")

</div>

Hi All,

I am new in Elastic search,

{  
"OrgDetailsLst" : [  
{  
"EntityId" : 3,  
"EntityDetailCode" : 0,  
"EntityName" : "PlantCode",  
"EntityCode" : "DRES",  
"Level" : 0  
},  
{  
"EntityId" : 5,  
"EntityDetailCode" : 0,  
"EntityName" : "CompanyCode",  
"EntityCode" : "0061",  
"Level" : 0  
}  
]  
}

I want 1 object as result from elastic search query where OrgDetailsLst is nested type array. I am executing query where OrgDetailsLst.EntityId =3 but its returning me whole array. Is there any other way to get exact match record as result.

I want result only this {  
"EntityId" : 3,  
"EntityDetailCode" : 0,  
"EntityName" : "PlantCode",  
"EntityCode" : "DRES",  
"Level" : 0  
},

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 15, 2020, 6:20am UTC](https://discuss.elastic.co/t/how-to-get-single-record-from-nested-type-array/228036/2 "2020-04-15T06:20:24Z")

</div>

Assuming you are using nested mappings you should be able to use [inner hits](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#request-body-search-inner-hits) although some level of post-processing may be required as it does not return a response in that exact format.

---

<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:** [May 13, 2020, 6:20am UTC](https://discuss.elastic.co/t/how-to-get-single-record-from-nested-type-array/228036/3 "2020-05-13T06:20:31Z")

</div>

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