Skip to content

DOCS-3338 added note about sort order to $near and geoNear. #1756

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 3 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
5 changes: 5 additions & 0 deletions source/core/2dsphere.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ coordinate pair with the ``[ 0 , 0 ]`` coordinate:
}
}

For Polygons with a single ring:

- The ring cannot self-intersect.


For Polygons with multiple rings:

- The first described ring must be the exterior ring.
Expand Down
9 changes: 9 additions & 0 deletions source/reference/command/geoNear.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Definition
of :query:`$near`, :dbcommand:`geoNear` returns additional
diagnostic information.

.. note::

The :dbcommand:`geoNear` always returns the documents sorted by distance.
Any other sort order requires to sort the documents in memory, which can
be inefficient. If another sort order is desired, use the
:operator:`$geoWithin` operator in combination with :method:`sort()`
instead.


The :dbcommand:`geoNear` command can use either a :term:`GeoJSON`
point or :term:`legacy coordinate pairs`. Queries that use a ``2d``
index return a limit of 100 documents.
Expand Down
9 changes: 9 additions & 0 deletions source/reference/operator/query/near.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ $near
closest documents first. The query sorts the documents from nearest
to farthest.

.. note::

The :dbcommand:`geoNear` always returns the documents sorted by distance.
Any other sort order requires to sort the documents in memory, which can
be inefficient. If another sort order is desired, use the
:operator:`$geoWithin` operator in combination with :method:`sort()`
instead.


The :query:`$near` operator can query for a :term:`GeoJSON`
point or for a point defined by legacy coordinate pairs.

Expand Down