Edit

Share via


Azure Cosmos DB for MongoDB (vCore) operators

This article contains details for various supported operators you can use with Azure Cosmos DB for MongoDB (vCore).

Aggregation

Description
$count The $count stage in the aggregation pipeline is used to count the number of documents that pass through the pipeline.
$facet The $facet stage aggregation pipelines allow for multiple parallel aggregations to be executed within a single pipeline stage.
$geonear The $geoNear aggregation stage calculates distances between a specified point and the location field in each document, sorts the documents by distance, and can optionally limit results by distance.
$lookup The $lookup stage in the Aggregation Framework is used to perform left outer joins with other collections.
$match The $match stage in the aggregation pipeline is used to filter documents that match a specified condition.

Array expression

Description
$arrayToObject The $arrayToObject operator is used to convert an array into a single document.
$concatArrays The $concatArrays operator is used to combine multiple arrays into a single array.
$filter The $filter operator is used to filter elements from an array based on a specified condition.
$indexOfArray The $indexOfArray operator is used to search for an element in an array and return the index of the first occurrence of the element.
$map The $map operator in MongoDB is used to apply an expression to each element in an array and return an array with the applied results.
$reduce The $reduce operator is used to apply an expression to each element in an array and accumulate the results into a single value.
$reverseArray The $reverseArray operator is used to reverse the order of elements in an array.
$slice The $slice operator is used to return a subset of an array.
$sortArray The $sortArray operator is used to sort the elements of an array.
$zip The $zip operator is used to merge two or more arrays element-wise into a single array of arrays.

Array query

Description
$all The $all operator is used to select documents where the value of a field is an array that contains all the specified elements.
$elemMatch The $elemMatch operator is used to match documents that contain an array field with at least one element that matches all the specified query criteria.
$size The $size operator is used to query documents where an array field has a specified number of elements.

Array update

Description
$each The $each operator is used within an $addToSet or $push operation to add multiple elements to an array field in a single update operation.
$positional The $position is used to specify the position in the array where a new element should be inserted.
$pullAll The $pullAll operator removes all instances of the specified values from an existing array.
$push The $push operator appends a specified value to an array.
$slice The $slice operator limits the number of array elements that are returned or modified.
$sort The $sort operator sorts the elements of an array.

Bitwise query

Description
$bitsAllClear The $bitsAllClear operator is used to match documents where all the bit positions specified in a bitmask are clear (that is, 0).
$bitsAllSet The $bitsAllSet operator is used to match documents where all the bit positions specified in a bitmask are set (that is, 1).
$bitsAnyClear The $bitsAnyClear operator is used to match documents where any bit positions specified in a bitmask are clear (that is, 0).
$bitsAnySet The $bitsAnySet operator is used to match documents where any bit positions specified in a bitmask are set (that is, 1).

Comparison query

Description
$eq The $eq operator matches documents where the value of a field equals the specified value.

Data expression

Description
$dateadd The $dateAdd operator adds a specified number of time units to a date value.
$datediff The $dateDiff operator returns the difference between two dates.
$datefromparts The $dateFromParts operator constructs a date from the specified parts.
$datefromstring The $dateFromString operator converts a date/time string to a date object.

Evaluation query

Description
$expr The $expr operator allows the use of aggregation expressions within the query language.

Geospatial

Description
$geoIntersect The $geoIntersects operator selects documents whose geospatial data intersects with a specified GeoJSON object.

Logical query

Description
$and The $and operator joins query clauses with a logical AND and returns all documents that match the conditions of both clauses.
$nor The $nor operator performs a logical NOR operation on an array of one or more query expressions and selects the documents that fail all the query expressions in the array.
$not The $not operator inverts the effect of a query expression and returns documents that don't match the query expression.
$or The $or operator performs a logical OR operation on an array of two or more expressions and selects the documents that satisfy at least one of the expressions.

Object expression

Description
$mergeObjects The $mergeObjects operator combines multiple documents into a single document.
$objectToArray The $objectToArray operator converts a document (object) into an array of key-value pairs.
$setField The $setField operator sets or updates the value of a field in a document.

Projection

Description
$elemMatch The $elemMatch projection operator limits the contents of an array field from the query results to contain only those array elements that match the specified query condition.
$meta The $meta projection operator returns metadata about the query, such as the text score.
$slice The $slice projection operator limits the number of elements projected from an array field.