- Reference >
- Operators >
- Query Modifiers >
- $natural
$natural¶
On this page
Definition¶
-
$natural
¶ Use the
$natural
operator to use natural order for the results of a sort operation. Natural order refers to the logical ordering of documents internally within the database.The
$natural
operator uses the following syntax to return documents in the order they exist on disk:
Behavior¶
On a sharded collection the $natural
operator returns a
collection scan sorted in natural order, the
order the database inserts and stores documents on disk.
Queries that include a sort by $natural
order do not
use indexes to fulfill the query predicate with the following
exception: If the query predicate is an equality condition on the
_id
field { _id: <value> }
, then the query with the sort by
$natural
order can use the _id
index.
You cannot specify $natural
sort order if the query
includes a $text
expression.
Examples¶
Reverse Order¶
Use { $natural: -1 }
to return documents in the reverse order as
they occur on disk: