Aggregates are similar to DSL query expressions, Aggregates also have a composable syntax: the functionality of individual units can be mixed to provide the custom behavior you need, you just need to understand two main concepts:
- Buckets
- A collection of documents that meet certain criteria
- Metrics
- Perform statistical calculations on documents in a bucket
Each aggregate is a combination of one or more buckets and zero or more metrics. Similar to the following SQL statement:
SELECT COUNT(color)
FROM table
GROUP BY color
OUNT(color) is equivalent to an indicator, and GROUP BY color is equivalent to a bucket.
Buckets are conceptually similar to SQL's GROUP BY, while indicators are similar to statistical methods such as COUNT()
, , SUM()
, MAX()
etc.