Aggregation Stage

noun

say it: “ag-rih-GAY-shun STAYJ” /ˌæɡrɪˈɡeɪʃən ˈsteɪdʒ/

One step in a MongoDB aggregation pipeline, such as filtering or grouping, that works on the documents the step before it passed on.

What is an aggregation stage?

An aggregation stage is one step of an aggregation pipeline, written as a document whose one field names its job, such as $match or $group. Each stage works on the documents the stage before it handed on, and passes its own results to the next.

db.orders.aggregate([
  { $match: { category: "bikes" } },                // stage 1: keep the bike orders
  { $group: { _id: "$store", sold: { $sum: 1 } } }  // stage 2: count them per store
]);

In a sentence

  • “The report's first aggregation stage is $match, so the later steps see only this year's orders.”
  • “Each aggregation stage is its own document in the pipeline's list.”

Level: Journeyman · More MongoDB terms at this level

Updated