# Return array element with a matching id

**URL:** <https://discuss.elastic.co/t/return-array-element-with-a-matching-id/123494>\
**Category:** Elasticsearch\
**Created:** [March 12, 2018, 7:46am UTC](https://discuss.elastic.co/t/return-array-element-with-a-matching-id/123494 "2018-03-12T07:46:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhilash\_Sathe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhilash_sathe/32/28555_2.png) [@Abhilash\_Sathe](https://discuss.elastic.co/u/Abhilash_Sathe)\
**Post date:** [March 12, 2018, 7:46am UTC](https://discuss.elastic.co/t/return-array-element-with-a-matching-id/123494/1 "2018-03-12T07:46:53Z")

</div>

Request:  
{  
"query": {  
"match": {  
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIyODA5MjA1MTQ4NQ=="  
}  
}  
}

Response:  
{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"skipped": 0,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1.2039728,  
"hits": [  
{  
"\_index": "shopify",  
"\_type": "products",  
"\_id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIyODA5MjA1MTQ4NQ==",  
"\_score": 1.2039728,  
"\_source": {  
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIyODA5MjA1MTQ4NQ==",  
"createdAt": "2017-10-23T11:05:40Z",  
"updatedAt": "2018-03-10T05:24:40Z",  
"descriptionHtml": "Et blanditiis autem. Molestiae delectus vero voluptatem libero cum. Aliquam tempore ex id sed aut excepturi facilis sunt.",  
"description": "Et blanditiis autem. Molestiae delectus vero voluptatem libero cum. Aliquam tempore ex id sed aut excepturi facilis sunt.",  
"handle": "future-proofed-re-engineered-handmade-cotton-chicken",  
"productType": "Computers",  
"title": "Future-proofed Re-engineered Handmade Cotton Chicken",  
"vendor": "Bednar LLC",  
"tags": [  
{  
"value": "data-generator"  
}  
],  
"publishedAt": "2018-03-07T08:25:38Z",  
"onlineStoreUrl": null,  
"options": [  
{  
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0T3B0aW9uLzM2NTQ0NDI2ODA2MQ==",  
"name": "Title",  
"values": [  
{  
"value": "Concrete blue - 71y-9a6"  
},  
{  
"value": "Concrete teal - oxh-g1z"  
}  
]  
}  
],  
"images": [],  
"variants": [  
{  
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMzczOTAzODcyMDI5",  
"title": "Concrete blue - 71y-9a6",  
"price": "82.00",  
"weight": 14,  
"available": true,  
"sku": "",  
"compareAtPrice": null,  
"image": null,  
"selectedOptions": [  
{  
"name": "Title",  
"value": "Concrete blue - 71y-9a6"  
}  
],  
"product": {  
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIyODA5MjA1MTQ4NQ==",  
"images": []  
}  
},  
{  
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMzczOTA0MDAzMTAx",  
"title": "Concrete teal - oxh-g1z",  
"price": "196.00",  
"weight": 7,  
"available": true,  
"sku": "",  
"compareAtPrice": null,  
"image": null,  
"selectedOptions": [  
{  
"name": "Title",  
"value": "Concrete teal - oxh-g1z"  
}  
],  
"product": {  
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIyODA5MjA1MTQ4NQ==",  
"images": []  
}  
}  
]  
}  
}  
]  
}  
}

Now let's say, I want a particular object from the variants array by using something like variants.id or variants.price. What should my query further be?

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [March 12, 2018, 8:06am UTC](https://discuss.elastic.co/t/return-array-element-with-a-matching-id/123494/2 "2018-03-12T08:06:12Z")

</div>

It is not possible to request a specific nested document from Elasticsearch, or to get a specific item out of an array within a document; queries and filters determine which documents come back, and in what order, but cannot be used to subdivide values from a particular 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:** [April 9, 2018, 8:06am UTC](https://discuss.elastic.co/t/return-array-element-with-a-matching-id/123494/3 "2018-04-09T08:06:35Z")

</div>

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