Skip to content

Compound index sort rephrasing & typo fix #2745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/core/index-compound.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ as well as both ``item`` and ``stock`` fields:
.. code-block:: javascript

db.products.find( { item: "Banana" } )
db.products.find( { item: "Banana", stock: { gt: 5 } } )
db.products.find( { item: "Banana", stock: { $gt: 5 } } )

For details, see :ref:`compound-index-prefix`.

Expand Down
12 changes: 6 additions & 6 deletions source/tutorial/sort-results-with-indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ appear in the index. For example, an index key pattern ``{ a: 1, b: 1
}`` can support a sort on ``{ a: 1, b: 1 }`` but *not* on ``{ b: 1, a:
1 }``.

The sort must specify the *same sort direction*
(i.e.ascending/descending) for all its keys as the index key pattern or
specify the *reverse sort direction* for all its keys as the index key
pattern. For example, an index key pattern ``{ a: 1, b: 1 }`` can
support a sort on ``{ a: 1, b: 1 }`` and ``{ a: -1, b: -1 }`` but *not*
on ``{ a: -1, b: 1 }``.
For a query to use a compound index for a sort, the specified sort direction
for all keys in the :method:`cursor.sort()` document must match the index
key pattern *or* match the inverse of the index key pattern.
For example, an index key pattern ``{ a: 1, b: -1 }`` can
support a sort on ``{ a: 1, b: -1 }`` and ``{ a: -1, b: 1 }`` but **not**
on ``{ a: -1, b: -1 }`` or ``{a: 1, b: 1}``.

.. _sort-index-prefix:

Expand Down