This version of the documentation is archived and no longer supported.


Aggregations operations process data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result. MongoDB provides three ways to perform aggregation: the aggregation pipeline, the map-reduce function, and single purpose aggregation methods and commands.

You can download this section in PDF form as MongoDB Aggregation and Data Processing.

Aggregation Introduction
A high-level introduction to aggregation.
Aggregation Concepts

Introduces the use and operation of the data aggregation modalities available in MongoDB.

Aggregation Pipeline
The aggregation pipeline is a framework for performing aggregation tasks, modeled on the concept of data processing pipelines. Using this framework, MongoDB passes the documents of a single collection through a pipeline. The pipeline transforms the documents into aggregated results, and is accessed through the aggregate database command.
Map-reduce is a generic multi-phase data aggregation modality for processing quantities of data. MongoDB provides map-reduce with the mapReduce database command.
Single Purpose Aggregation Operations
MongoDB provides a collection of specific data aggregation operations to support a number of common data aggregation functions. These operations include returning counts of documents, distinct values of a field, and simple grouping operations.
Aggregation Mechanics
Details internal optimization operations, limits, support for sharded collections, and concurrency concerns.
Aggregation Examples
Examples and tutorials for data aggregation operations in MongoDB.
Aggregation Reference
References for all aggregation operations material for all data aggregation methods in MongoDB.