Pipelines

Pipeline aggregation allows for querying, aggregating, and transforming data in multiple stages in real-time through a single API request. While query arguments allow for making simple, single-stage queries through the API, pipelines allow for more complex searches, aggregations and transformations.

To leverage pipeline aggregation via the API, simply pass a pipeline query argument with the request. The pipeline query argument is an array of pipeline stages that execute in order. Each stage transforms the result set and passes it on to the next stage in the pipeline.

?pipeline=[{ stage1 },{ stage2 }, { stage3 }, ...]

Name

Description

$group

Outputs a cursor containing specified groups of elements from the previous cursor. Groups may make use of accumulator expressions.

$limit

Outputs a cursor containing a limited number of elements from the previous cursor

$match

Outputs a cursor containing a subset of elements from the previous cursor which satisfy a set matching criteria.

$project

A JSON object that specifies existing properties or new properties to pass along to the next stage in the pipeline.

$skip

An integer representing the number of results to skip. Useful for paging where mapping or groupings have been applied, or where search the search criteria cannot be paged using unique fields.

$sort

A JSON object containing one or more properties, the values of which must be 1 for ascending and -1 for descending

$count

Exhausts an input cursor and outputs a cursor with a single element specifying the total number of elements within the input cursor.

$cursor

Outputs a cursor containing the results of a database query and exhausts any previous cursors to dev/null

$output

N/A

$transform

N/A

$var

N/A

Last updated