I'm working on Elasticsearch aggregations, and I would like to get a single value that aggregates the values for all records. I can cheat with a "Range >= 0" aggregation, but is there a more idiomatic way?
My kludgy query is:
{
"size": 0,
"aggs": {
"all": {
"range": {
"field": "price",
"ranges": [{"from": 0}] }
}
},
"aggs": {
"total price": {
"avg": {"field": "price"}}
}
}
}
ES has built this into the "stats" aggregation for you, use the "sum" result.
Result: