Return array element with a matching id

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?

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.

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