# Get only one row of nested object in a filter query

**URL:** https://discuss.elastic.co/t/get-only-one-row-of-nested-object-in-a-filter-query/178696
**Category:** Elasticsearch
**Created:** [April 26, 2019, 5:06pm UTC](https://discuss.elastic.co/t/get-only-one-row-of-nested-object-in-a-filter-query/178696 "2019-04-26T17:06:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![adriamuixi](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@adriamuixi](https://discuss.elastic.co/u/adriamuixi)
#### Post date: [April 26, 2019, 5:06pm UTC](https://discuss.elastic.co/t/get-only-one-row-of-nested-object-in-a-filter-query/178696/1 "2019-04-26T17:06:16Z")

</div>

Hi

With ElasticSearch 6.5 I have this document product data mapped with nested Objects (variants and price) :

```
 {
 	"name": "Test",
 	"variants": [{
 		"id": 767898,
 		"sku_variant": "HK-334455-NSO",
 		"visibility": "4",
 		"replenishment": "0",
 		"stock": "0.0000",
 		"value": "default",
 		"attribute": null,
 		"price": [{
 				"code": "AD",
 				"pvp": 140.0,
 				"currency_code": "EUR",
 				"price": 125.95
 			},
 			{
 				"code": "AE",
 				"pvp": 580.9732599995936,
 				"currency_code": "AED",
 				"price": 522.6684435496344
 			},
 			{
 				"code": "AF",
 				"pvp": 158.1732600000627,
 				"currency_code": "USD",
 				"price": 142.29944355005642
 			},
 			{
 				"code": "AG",
 				"pvp": 158.1732600000627,
 				"currency_code": "USD",
 				"price": 142.29944355005642
 			},
 			{
 				"code": "AI",
 				"pvp": 158.1732600000627,
 				"currency_code": "USD",
 				"price": 142.29944355005642
 			}
 		]
 	}]
 }

```

Is possible to search by price and only get the row with "code": "AG". The result have to contain all the fields , sku, replenishment, sock, price and price would have only one element, this one:

```
            {
              "code" : "AG",
              "pvp" : 158.1732600000627,
              "currency_code" : "USD",
              "price" : 142.29944355005642
            }

```

Is it possible to find a query filter to get this result?

the result will be:

```
{
	"name": "Test",
	"variants": [{
		"id": 767898,
		"sku_variant": "HK-334455-NSO",
		"visibility": "4",
		"replenishment": "0",
		"stock": "0.0000",
		"value": "default",
		"attribute": null,
		"price": [{
			"pvp": 158.1732600000627,
			"currency_code": "USD",
			"price": 142.29944355005642
		}]
	}]
}

```

Thanks in advance

---

<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 24, 2019, 5:06pm UTC](https://discuss.elastic.co/t/get-only-one-row-of-nested-object-in-a-filter-query/178696/2 "2019-05-24T17:06:17Z")

</div>

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