Skip to main content
Aggregate stage showing statistical computations on search results
The Aggregate stage computes statistical aggregations across your search results, including counts, sums, averages, min/max values, and custom metrics. This is useful for analytics, faceted search, and understanding result distributions.
Stage Category: REDUCE (Aggregates results)Transformation: N documents → aggregation results + optional documents
Aggregating a whole collection? The collection-level endpoint POST /v1/collections/{collection_id}/aggregate runs the same functions over every matching document (not just the current pipeline’s results) and returns exact counts at any collection size — count, count_distinct, sum, avg, min, and max stream without a row cap. Pair it with the is_null filter operator for field-presence / data-validity checks, e.g. count how many documents are missing an ancestor (from_collection) field across 180k+ assets.

When to Use

When NOT to Use

Parameters

Aggregation Types

Configuration Examples

Output Schema

Without Group By

With Group By

Histogram Output

Performance

Common Pipeline Patterns

Search with Facets

Analytics Pipeline

E-Commerce Product Analytics

Aggregation Details

Count

Counts documents. No field required.

Sum / Avg / Min / Max

Requires numeric field.

Cardinality

Counts unique values (approximate for large sets).

Percentile

Returns specified percentile values.

Histogram

Groups values into buckets.

Statistical Aggregation Examples

Statistical Output Examples

Frequency returns value counts with percentages:
Co-occurrence returns field pair counts:
Correlation returns the Pearson coefficient (-1 to 1):

Error Handling