## Aggregation 

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 (page 440), the map-reduce function (page 442), and single purpose aggregation methods and commands (page 444). 

Aggregation Introduction (page 435) A high-level introduction to aggregation. 

Aggregation Concepts (page 439) Introduces the use and operation of the data aggregation modalities available in MongoDB. 

Aggregation Pipeline (page 440) The aggregation pipeline is a framework for performing aggregation tasks, modeled on the concept of data processing pipelines. Using this framework, MongoDB passes the doc- uments 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 (page 442) Map-reduce is a generic multi-phase data aggregation modality for processing quan- tities of data. MongoDB provides map-reduce with the mapReduce database command. 

Single Purpose Aggregation Operations (page 444) MongoDB provides a collection of specific data aggrega- tion 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 (page 447) Details internal optimization operations, limits, support for sharded col- lections, and concurrency concerns. 

Aggregation Examples (page 452) Examples and tutorials for data aggregation operations in MongoDB. 

Aggregation Reference (page 469) References for all aggregation operations material for all data aggregation meth- ods in MongoDB. 

## 7.1 Aggregation Introduction 

Aggregations are operations that process data records and return computed results. MongoDB provides a rich set of aggregation operations that examine and perform calculations on the data sets. Running data aggregation on the mongod instance simplifies application code and limits resource requirements. 

Like queries, aggregation operations in MongoDB use collections of documents as an input and return results in the form of one or more documents. 

