This version has reached end of life on October 2016. Learn more about upgrading your version of MongoDB.

Query Modifiers

On this page


In addition to the MongoDB Query Operators, there are a number of “meta” operators that let you modify the output or behavior of a query. On the server, MongoDB treats the query and the options as a single object. The mongo shell and driver interfaces may provide cursor methods that wrap these options. When possible, use these methods; otherwise, you can add these options using either of the following syntax:

db.collection.find( { <query> } )._addSpecial( <option> )
db.collection.find( { $query: { <query> }, <option> } )



Many of these operators have corresponding methods in the shell. These methods provide a straightforward and user-friendly interface and are the preferred way to add these options.

Name Description
$comment Adds a comment to the query to identify queries in the database profiler output.
$explain Forces MongoDB to report on query execution plans. See explain().
$hint Forces MongoDB to use a specific index. See hint()
$maxScan Limits the number of documents scanned.
$maxTimeMS Specifies a cumulative time limit in milliseconds for processing operations on a cursor. See maxTimeMS().
$max Specifies an exclusive upper limit for the index to use in a query. See max().
$min Specifies an inclusive lower limit for the index to use in a query. See min().
$orderby Returns a cursor with documents sorted according to a sort specification. See sort().
$returnKey Forces the cursor to only return fields included in the index.
$showDiskLoc Modifies the documents returned to include references to the on-disk location of each document.
$snapshot Forces the query to use the index on the _id field. See snapshot().
$query Wraps a query document.

Sort Order

Name Description
$natural A special sort order that orders documents using the order of documents on disk.