Skip to content

Commit cb3e944

Browse files
authored
DOCS-15596 Revises Sort for $near and $nearSphere (#2577) (#2588)
* DOCS-15596 Adds section on / in aggregation pipelines * Adjusts include text * Adjusts include text * Fixes build * Fixe per Maddie Zechar * Fixes per Maddie * Fixes per Maddie * Fixes per Dave * Fixes per Dave * Fixes per Dave * Fixes per Dave
1 parent 0c48706 commit cb3e944

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

source/includes/example-near-minDistance.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
.. important::
2-
.. include:: /includes/extracts/geospatial-long-lat-values.rst
1+
.. include:: /includes/extracts/geospatial-long-lat-values.rst
32

43
Consider a collection ``places`` that has a ``2dsphere`` index.
54

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
|geo-operation| sorts documents by distance. If you also include a
2-
:method:`~cursor.sort()` for the query, :method:`~cursor.sort()`
3-
re-orders the matching documents, effectively overriding the sort
4-
operation already performed by |geo-operation|. When using
5-
:method:`~cursor.sort()` with geospatial queries, consider using
6-
:query:`$geoWithin` operator, which does not sort documents, instead of
7-
|geo-operation|.
1+
The |geo-operation| operator sorts documents by distance.
2+
3+
- If you use the :method:`~cursor.sort` method in your query,
4+
MongoDB performs a second sort operation, re-ordering the matching
5+
documents. When querying large collections, this can negatively
6+
affect query performance.
7+
8+
- If the order of the documents is not important to you, consider
9+
using the :query:`$geoWithin` operator instead, as it returns
10+
unsorted results.
11+
12+
- |geo-operation| is a Match Execution operator and is not
13+
permitted in aggregation pipelines.
14+

source/reference/operator/query/nearSphere.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Sort Operation
9797

9898
.. |geo-operation| replace:: :query:`$nearSphere`
9999

100+
100101
Examples
101102
--------
102103

0 commit comments

Comments
 (0)