Stage Category: REDUCE (Aggregates results)Transformation: N documents → aggregation results + optional documents
Aggregating a whole collection? Use
Every operation needs
POST /v1/collections/{collection_identifier}/documents/aggregate. It runs the
same functions over every matching document, not just the current pipeline’s
results. It returns exact counts at any collection size, and count,
count_distinct, sum, avg, min and max stream without a row cap. Pair
it with the is_null filter operator for field-presence checks, such as
counting documents missing a from_collection ancestor across 180k+ assets.That endpoint does not take this stage’s shape. Three names differ:group_by and aggregations are both required, each with at least one entry:function and alias. field is required for every
function except count. count_distinct takes distinct_field instead.
