Nested Range Aggregation

Hi there,

Based on the following data:

"hits": {
"total": 2,
"hits": [
{
"_id": "PRODUCT A",
"inner_hits": {
"doc.products": {
"hits": {
"total": 1,
"hits": [
{
"doc.products.productCode": "PRODUCT A",
"inner_hits": {
"doc.products.calculatedPrices": {
"hits": {
"hits": [
{
"doc.products.calculatedPrices.now": 100
}
]
}
}
}
}
]
}
}
}
},
{
"_id": "PRODUCT B",
"inner_hits": {
"doc.products": {
"hits": {
"total": 2,
"hits": [
{
"doc.products.productCode": "PRODUCT B",
"inner_hits": {
"doc.products.calculatedPrices": {
"hits": {
"doc.products.calculatedPrices.now": 200
},
{
"doc.products.calculatedPrices.now": 201
}
]
}
}
}
},
{
"doc.products.productCode": "PRODUCT B",
"inner_hits": {
"doc.products.calculatedPrices": {
"hits": {
"doc.products.calculatedPrices.now": 300
},
{
"doc.products.calculatedPrices.now": 301
},
{
"doc.products.calculatedPrices.now": 302
}
]
}
}
}
}
]
}
}
}
}
]
}

Is it possible to do a range aggregation based on the lowest calculated price for all the products for each document and uses that value, for the range, something like this

"prices": {
"price_ranges": {
"prices": {
"buckets": {
"0-200": {
"from": 0,
"to": 199,
"price_range_count": {
"doc_count": 1
}
},
"200-399": {
"from": 200,
"to": 399,
"price_range_count": {
"doc_count": 1
}
}
}
}
}
}

Thank you in advance

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