Sum of unique ids

Ok cool, that makes things easier.

What I would do is:

  • terms aggregation on ID
    • max metric aggregation on quantity. Because all the quantities will be the same, a max (or min) will just return the value.
    • sum_bucket pipeline aggregation to add up all the quantities. Pipeline aggregations act on the result of other aggs, so this sum_bucket will point to the max metric and sum them all up.
1 Like