Docs Menu
Docs Home
/
MongoDB Manual
/ /

Query Predicates

On this page

  • Alphabetical List of Operators

Query predicates are expressions that return a boolean that indicates whether a document matches a specified query. For example, { name: { $eq: "Alice" } } is a query predicate that returns documents where the value of the "name" field is the string "Alice".

To match the correct documents, you can use the following types of operators in query predicates:

Operator Type
Description

Array Query Predicate Operators

Return data based on array conditions.

Return data based on bit position conditions.

Return data based on value comparisons such as less than and greater than.

Return data based on field existence or data types.

Perform specialized functions in query predicates.

Return data based on boolean logic (and, or, and nor).

Return data based on geospatial query predicates, such as containment within a region on the surface of the Earth.

Name
Description

Matches arrays that contain all elements specified in the query.

Joins query clauses with a logical AND and returns documents that match the conditions of all clauses.

Matches numeric or binary values in which a set of bit positions all have a value of 0.

Matches numeric or binary values in which a set of bit positions all have a value of 1.

Matches numeric or binary values in which any bit from a set of bit positions has a value of 0.

Matches numeric or binary values in which any bit from a set of bit positions has a value of 1.

Selects documents if at least one element in the array field matches all the specified $elemMatch conditions.

Matches values that are equal to a specified value.

Matches documents that have the specified field.

Allows use of expressions in query predicates.

Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects.

Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin.

Matches values that are greater than a specified value.

Matches values that are greater than or equal to a specified value.

Validates documents against the given JSON Schema.

Matches any of the values specified in an array.

Matches values that are less than a specified value.

Matches values that are less than or equal to a specified value.

Matches documents based on the result of a modulo operation on a field value.

Matches all values that are not equal to a specified value.

Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near.

Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere.

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

Joins query clauses with a logical NOR and returns all documents that fail to match all clauses.

Inverts the effect of a query predicate and returns documents that do not match the query predicate.

Joins query clauses with a logical OR and returns all documents that match at least one clause.

Matches documents where values match a specified regular expression.

Selects documents if the array field contains the specified number of elements.

Matches documents if a field is of the specified type.

Matches documents that satisfy a JavaScript expression.

Back

$vectorSearch