For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Comparison Query Predicate Operators

Comparison operators filter data with value comparisons such as less than and greater than.

Inequality comparison operators ($gt, $gte, $lt, and $lte) use type bracketing, which means a comparison on a given BSON type matches only values of that type. Negations ($ne and $nin) don't use type bracketing, so they match values of any type.

Unlike the query predicates, the inequality comparison expressions ($gt, $gte, $lt, and $lte) don't use type bracketing. Instead, they compare values of different BSON types using the specified BSON comparison order.

Operator
Description

Matches values equal to a specified value.

Matches values greater than a specified value.

Matches values greater than or equal to a specified value.

Matches any values specified in an array.

Matches values less than a specified value.

Matches values less than or equal to a specified value.

Matches all values not equal to a specified value.

Matches if the value is not equal to any of a given list of values.

Rate this page