Hi!
Given docs as the ones in the example below:
{ "id" : "1", "numValue": 9.7 }
{ "id" : "1", "numValue": 9.7 }
{ "id" : "1", "numValue": 9.7 }
{ "id" : "2", "numValue": 7 }
{ "id" : "2", "numValue": 7 }
{ "id" : "3", "numValue": 10 }
I'm trying to create a query that groups the docs by id like this (a simple terms aggregation):
{ "id" : "1", "numValue": 9.7 }
{ "id" : "2", "numValue": 7 }
{ "id" : "3", "numValue": 10 }
And then sums the "numValue": in this example 9.7 + 7 + 10.
I know I can get the first part done by using a max aggregation inside a terms, but I don't know how to get the total sum:
"aggs": {
"group_by_ID": {
"terms": {
"field": "ID",
"min_doc_count": 1
},
"aggs": {
"maxValue": {
"max": {
"field": "numvalue"
}
}
}
}
}
I've also tried to add a sum aggregation that sums "maxValue", but the result is always 0.
A visualization would be a good option too, if it's easier that way, but it would need be compatible with Kibana 7.9.2.
Any help would be appreciated!
Kind regards,
Miguel