ElasticGraph Query API: Aggregated Values
Aggregated values can be computed from all values of a particular field from all documents backing an aggregation node. Here’s an example:
This example query aggregates the values of the Artist.lifetimeSales
field using all 4 of the standard numeric
aggregated values: min
, max
, avg
, and sum
. These are qualified with approximate
or exact
to indicate
the level of precision they offer. The documentation for approximateSum
and exactSum
provide more detail:
approximateSum
- The (approximate) sum of the field values within this grouping.
Sums of large
Int
values can result in overflow, where the exact sum cannot fit in aJsonSafeLong
return value. This field, as a double-precisionFloat
, can represent larger sums, but the value may only be approximate. exactSum
- The exact sum of the field values within this grouping, if it fits in a
JsonSafeLong
.Sums of large
Int
values can result in overflow, where the exact sum cannot fit in aJsonSafeLong
. In that case,null
will be returned, andapproximateSum
can be used to get an approximate value.
Besides these standard numeric aggregated values, ElasticGraph offers one more:
The approximateDistinctValueCount
field uses the HyperLogLog++ algorithm
to provide an approximate count of distinct values for the field. In this case, it can give us an idea of how many countries ska
bands were formed in, in each year.