Skip to content

Commit e72371a

Browse files
authored
DOCS-15596 Revises Sort for $near and $nearSphere (#2577) (#2590)
* 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 d07844e commit e72371a

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

source/includes/example-near-minDistance.rst

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

53
Consider a collection ``places`` that has a ``2dsphere`` index.
64

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/near.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ Sort Operation
9898

9999
:ref:`3.0-geo-near-compatibility`
100100

101-
102101
Examples
103102
--------
104103

source/reference/operator/query/nearSphere.txt

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

100100
.. |geo-operation| replace:: :query:`$nearSphere`
101101

102+
102103
Examples
103104
--------
104105

0 commit comments

Comments
 (0)