# $size

*noun*

say it: **“DOL-er SYZE”** **/ˈdɑlər ˈsaɪz/**

A MongoDB filter operator that matches an array with exactly a given number of items.

## What does **$size** do in a MongoDB filter?

**$size** matches documents whose array field has exactly the number of items you give. It takes one exact number, not a range such as "more than 5".

```javascript
db.recipes.find({ ingredients: { $size: 3 } }, { _id: 0, name: 1 });
// [ { name: 'Garlic Toast' } ]
```

## In a sentence

- “The 'three-ingredient recipes' page is one query with **$size** 3.”
- “**$size** can't say 'at least 3', so the app stores an ingredient count for that.”

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

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/size
