The aggregation pipeline is a framework for data aggregation modeled on the concept of data processing pipelines. Documents enter a multi-stage pipeline that transforms the documents into an aggregated results. New in version 2.2. MongoDB Documentation, Release 3.0.4 7.2.1 Aggregation Pipeline Pipeline The aggregation pipeline provides an alternative to map-reduce and may be the preferred solution for aggregation tasks where the complexity of map-reduce may be unwarranted. Aggregation pipeline have some limitations on value types and result size. See Aggregation Pipeline Limits (page 450) for details on limits and restrictions on the aggregation pipeline. The MongoDB aggregation pipeline consists of stages . Each stage transforms the documents as they pass through the pipeline. Pipeline stages do not need to produce one output document for every input document; e.g., some stages may generate new documents or filter out documents. Pipeline stages can appear multiple times in the pipeline. MongoDB provides the db.collection.aggregate() method in the mongo shell and the aggregate com- mand for aggregation pipeline. See aggregation-pipeline-operator-reference for the available stages. For example usage of the aggregation pipeline, consider Aggregation with User Preference Data (page 456) and Aggregation with the Zip Code Data Set (page 453). Chapter 7. Aggregation 440