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 }, ...]




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


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


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


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


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.


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


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


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







Last updated