The $min accumulator finds the lowest value in each $group bucket—ideal for cheapest prices, minimum scores, floor quantities, and range reports alongside $max.
01
Floor per group
Smallest value in the bucket.
02
Simple syntax
{ $min: "$field" }
03
No $sort needed
Scans all docs in group.
04
Expressions OK
Min of computed values.
05
vs $first
Floor value vs first doc.
06
Null handling
Skips null when others exist.
Fundamentals
Definition and Usage
$min is a MongoDB accumulator used in the $group stage. For each group, it evaluates an expression on every document and returns the minimum value found.
💡
Beginner tip
Unlike $first or $last, $min does not care about document order—it compares values across the whole group. Prices 25, 15, 20, and 10 yield 10 whether or not you sorted first.
Use $min for price floors, minimum test scores, lowest inventory levels, and quality thresholds. Pair with $max for min/max ranges, or use $bottomN when you need the full documents at the bottom of a ranked list.
Use $min + $max in one $group for price/score ranges
Filter with $match before $group to min only relevant documents
Use expressions when the floor of a computed value matters (line totals, durations)
Validate numeric types with $match: { field: { $type: "number" } } when data is messy
Use $bottom or $bottomN when you need identifying fields from the lowest record
❌ Don’t
Confuse $min with $first (floor vs first document’s value)
Assume $min returns the product name—it returns the minimum value only
Compare mixed types without understanding BSON type ordering
Expect $min to traverse into array elements inside $group
Use $min when you need N smallest values—use $minN instead
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about $min
Use these points when finding floor values inside $group.
5
Core concepts
📉01
Floor value
Lowest in the group.
Basics
📝02
Simple syntax
{ $min: "$field" }
Syntax
📊03
No $sort
Scans whole group.
Pattern
🔄04
vs $first
Floor vs leading doc.
Compare
💲05
+ $max
Min/max ranges.
Pair
❓ Frequently Asked Questions
$min returns the lowest value of an expression across all documents in each $group bucket. It scans every document in the group and picks the minimum—no $sort required.
Inside $group: { minPrice: { $min: "$price" } }. It also works as an expression in $project, $addFields, and window stages—but this tutorial focuses on the $group accumulator.
Grouping with _id: null puts all documents into one bucket, so $min returns a single overall minimum for the entire filtered collection.
If some documents have values and others are null or missing, $min ignores the null/missing ones. If every document lacks a usable value, $min returns null.
$min finds the smallest value anywhere in the group. $first returns a field from the first document in pipeline order—they differ when the lowest value is not on the first document.
$min returns the lowest value; $max returns the highest. Use both in the same $group for range summaries (min price and max price per category).
Did you know?
$min and $max use BSON comparison order, so dates, strings, and numbers compare by type rules—not just numeric magnitude. For the N smallest numbers specifically, MongoDB 5.2+ offers $minN. See the official $min docs.