Reputation: 14419
I need to group all records by a value of Field1, and calculate max value of Field2 for every group. So, is there any way to make max aggregation work over multiple groups within the same query?
Upvotes: 5
Views: 7659
Reputation: 4733
GET /yourindex/_search?search_type=count
{
"aggs": {
"yourGroup": {
"terms": {
"field": "field1",
"size": 10
},
"aggs": {
"theMax": {
"max": {
"field": "field2"
}
}
}
}
}
}
Upvotes: 15