I'm looking for a way to get the min and max value from a 2 level nested object which have been filtered. So below im trying to get the min and max price which has a currencyCode GBP. Each product can have multiple skus and each sku can have multiple prices (though only 1 will be GBP):
"hits": [
{
"_index": "product",
"_type": "main",
"_id": "1",
"_score": 1,
"_source": {
"skus": [
{
"prices": [
{
"currencyCode": "GBP",
"price": 15
}
]
}
]
}
},{
"_index": "product",
"_type": "main",
"_id": "2",
"_score": 1,
"_source": {
"skus": [
{
"prices": [
{
"currencyCode": "GBP",
"price": 20
}
]
}
]
}
},
{
"_index": "product",
"_type": "main",
"_id": "3",
"_score": 1,
"_source": {
"skus": [
{
"prices": [
{
"currencyCode": "GBP",
"price": 25
}
]
}
]
}
}]
}
So I want min 15, max 25. I've looked into Filter Aggregation and Nested Aggregation but can not come up with the answer.
I'm using ElasticSearch version 5.5.
I'm trying to get the query working correctly first before converting to Nest .net.
Any help would be much appreciated.