$lt means less than. Use it to filter documents where a field is below a value, or in aggregation to return true / false from a comparison. Equality does not match—use $lte for that.
Pick filter mode (keep documents) or expression mode (boolean field).
For filtering: use find() or $match with { field: { $lt: value } }.
For a boolean: use $addFields / $project with { $lt: [ expr1, expr2 ] }.
To compare two fields in a filter, wrap with $expr.
Use $lte when the boundary value should also match.
Piece
Required?
Role
Query form
—
{ field: { $lt: value } } filters docs
Expression form
—
{ $lt: [ a, b ] } → boolean
Operands
Yes
Same BSON type when possible
Pseudocode
Pseudocode
// Filter mode
for each document:
if field < threshold:
keep document
else:
drop document
// Expression mode
for each document:
result = (expr1 < expr2) // true or false
emit { ..., field: result }
Reference
Cheat Sheet
Keep these facts handy while writing less-than checks.
Same stored documents. Still using Asha and Ben from Example 1.
Compare as an expression.{ $lt: ["$score", 80] } returns a boolean per document.
Nothing is dropped. Both rows stay; only the new below flag differs.
Edge Cases & Pitfalls
Check these before using $lt in production queries.
equals
Equals do not match
{ score: { $lt: 80 } } excludes 80. Use $lte when the boundary should pass.
types
Type mismatches surprise
Comparing a number to a string uses BSON type order, not numeric math. Keep types consistent.
fields
Two fields need $expr in find
To filter with spent < budget, use $expr: { $expr: { $lt: ["$spent", "$budget"] } }.
index
Range filters love indexes
An index on the compared field helps $lt / $lte range scans stay fast on large collections.
Analysis
Performance Notes
Approach
Cost
Best for
Indexed $lt filter
Range scan
Large collections with a field index
Unindexed $lt
Collection scan
Small data or rare queries
Agg boolean $lt
Per-document compare
Flags without dropping rows
Put selective $lt filters early in $match so later stages see fewer documents.
Remember
Key Takeaways
Role: strict less-than comparison.
Filter:{ field: { $lt: value } }.
Expression:{ $lt: [ a, b ] } → boolean.
Equals: use $lte when the boundary should match.
One line:$lt answers “is this value strictly less than that?”—as a filter or as a boolean.
Frequently Asked Questions
$lt means less than. In a query filter it keeps documents where a field is below a value. In aggregation expressions it compares two expressions and returns true or false. Equality does not match.
Query form: { field: { $lt: value } }. Aggregation form: { $lt: [ <expression1>, <expression2> ] }. There is no shorthand for less-than.
$lt is strict less than (excludes equality). $lte is less than or equal (includes equality). Score 80 matches { score: { $lte: 80 } } but not { score: { $lt: 80 } }.
Yes in aggregation: { $lt: [ "$spent", "$budget" ] }. In a find filter, compare two fields with $expr and $lt.
Yes. Numbers compare numerically, dates chronologically, and strings lexicographically. Keep operand types consistent for predictable results.
In find() / $match filters to select documents, and in expression stages like $project and $addFields to create boolean fields.