# Aggregation Pipeline

*noun*

say it: **“ag-rih-GAY-shun PYPE-lyne”** **/ˌæɡrɪˈɡeɪʃən ˈpaɪplaɪn/**

A list of steps in MongoDB that documents pass through in order, each filtering, reshaping or summarizing them, to build results such as reports.

## What is **Aggregation Pipeline**?

The **aggregation pipeline** processes documents through stages, like `$match` then `$group` then `$sort`, to filter, reshape and summarize data, similar to SQL's GROUP BY and JOIN.

```javascript
db.orders.aggregate([
  { $match: { status: 'paid' } },
  { $group: { _id: '$customerId', total: { $sum: '$amount' } } },
  { $sort: { total: -1 } }
])
```

## In a sentence

- “The monthly report is one **aggregation pipeline**: $match, $group, $sort.”
- “An **aggregation pipeline** runs inside the database, so only the results travel to the app.”

Level: Journeyman · [More MongoDB terms at this level](https://www.ask-codey.com/glossary?category=mongodb&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/aggregation-pipeline
