MongoDB Documentation, Release 3.0.4 aggregate mapReduce group De- scrip- tion New in version 2.2. Designed with specific goals of improving performance and usability for aggregation tasks. Uses a “pipeline” approach where objects are transformed as they pass through a series of pipeline operators such as $group , $match , and $sort . See http://docs.mongodb.org/manual/reference/operator/aggregation for more information on the pipeline operators. Implements the Map-Reduce aggregation for processing large data sets. Provides grouping functionality. Is slower than the aggregate command and has less functionality than the mapReduce command. Key Fea- tures Pipeline operators can be repeated as needed. Pipeline operators need not produce one output document for every input document. Can also generate new documents or filter out documents. In addition to grouping operations, can perform complex aggregation tasks as well as perform incremental aggregation on continuously growing datasets. See Map-Reduce Examples (page 460) and Perform Incremental Map-Reduce (page 463). Can either group by existing fields or with a custom keyf JavaScript function, can group by calculated fields. See group for information and example using the keyf function. Flex- i- bil- ity Limited to the operators and expressions supported by the aggregation pipeline. However, can add computed fields, create new virtual sub-objects, and extract sub-fields into the top-level of results by using the $project pipeline operator. See $project for more information as well as http://docs.mongodb.org/manual/reference/operator/aggregation for more information on all the available pipeline operators. Custom map , reduce and finalize JavaScript functions offer flexibility to aggregation logic. See mapReduce for details and restrictions on the functions. Custom reduce and finalize JavaScript functions offer flexibility to grouping logic. See group for details and restrictions on these functions. Out- put Re- sults Returns results in various options (inline as a document that contains the result set, a cursor to the result set) or stores the results in a collection. The result is subject to the BSON Document size limit if returned inline as a document that contains the result set. Changed in version 2.6: Can return results as a cursor or store the results to a collection. Returns results in various options (inline, new collection, merge, replace, reduce). See mapReduce for details on the output options. Changed in version 2.2: Provides much better support for sharded map-reduce output than previous versions. Returns results inline as an array of grouped items. The result set must fit within the maximum BSON document size limit . Changed in version 2.2: The returned array can contain at most 20,000 elements; i.e. at most 20,000 unique groupings. Previous versions had a limit of 10,000 elements. Shard- ing Supports non-sharded and sharded input collections. Supports non-sharded and sharded input collections. Does not support sharded collection. Notes Prior to 2.4, JavaScript code executed in a single thread. Prior to 2.4, JavaScript code executed in a single thread. Mor e In- for- ma- tion See Aggregation Pipeline (page 440) and aggregate . See Map-Reduce (page 442) and mapReduce . See group . 7.4. Aggregation Reference 475