Get only one row of nested object in a filter query

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

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