@@ -37,150 +37,140 @@ Definition
37
37
.. list-table::
38
38
:header-rows: 1
39
39
:widths: 20 20 80
40
-
40
+
41
41
* - Field
42
-
42
+
43
43
- Type
44
-
44
+
45
45
- Description
46
-
47
- * - ``near``
48
-
49
- - GeoJSON point or :term:`legacy coordinate pair <legacy coordinate pairs>`
50
-
51
- - The point for which to find the closest documents.
52
-
53
- If using a :doc:`2dsphere </core/2dsphere>` index, you can specify
54
- the point as either a GeoJSON point or legacy coordinate pair.
55
-
56
- If using a :doc:`2d </core/2d>` index, specify the point as a legacy
57
- coordinate pair.
58
-
59
-
60
-
46
+
47
+
61
48
* - ``distanceField``
62
-
49
+
63
50
- string
64
-
51
+
65
52
- The output field that contains the
66
53
calculated distance. To specify a field within an embedded document,
67
54
use :term:`dot notation`.
68
-
69
-
70
-
71
- * - ``spherical``
72
-
73
- - boolean
74
-
75
- - Optional. Determines how MongoDB calculates the distance between two points:
76
-
77
- - When ``true``, MongoDB uses :query:`$nearSphere` semantics and
78
- calculates distances using spherical geometry.
79
-
80
- - When ``false``, MongoDB uses :query:`$near` semantics:
81
- spherical geometry for :doc:`2dsphere </core/2dsphere>`
82
- indexes and planar geometry for :doc:`2d </core/2d>` indexes.
83
-
84
- *Default: false.*
85
-
86
-
87
-
88
- * - ``maxDistance``
89
-
90
- - number
91
-
92
- - Optional. The maximum distance from the center point that the documents *can*
93
- be. MongoDB limits the results to those documents that fall within
94
- the specified distance from the center point.
95
-
96
- Specify the distance in meters if the specified point is
97
- :term:`GeoJSON` and in radians if the specified point is
98
- :term:`legacy coordinate pairs <legacy coordinate pairs>`.
99
-
100
-
101
-
102
- * - ``query``
103
-
104
- - document
105
-
106
- - Optional. Limits the results to the documents that match the query. The query
107
- syntax is the usual MongoDB :ref:`read operation query
108
- <read-operations-query-argument>` syntax.
109
-
110
- .. include:: /includes/fact-geoNear-restrict-near-in-query.rst
111
-
112
-
113
-
55
+
56
+
114
57
* - ``distanceMultiplier``
115
-
58
+
116
59
- number
117
-
60
+
118
61
- Optional. The factor to multiply all distances returned by the query. For
119
62
example, use the ``distanceMultiplier`` to convert radians, as
120
63
returned by a spherical query, to kilometers by multiplying by the
121
64
radius of the Earth.
122
-
123
-
124
-
65
+
66
+
125
67
* - ``includeLocs``
126
-
68
+
127
69
- string
128
-
70
+
129
71
- Optional. This specifies the output field that identifies the location used to
130
72
calculate the distance. This option is useful when a location field
131
73
contains multiple locations. To specify a field within an
132
74
embedded document, use :term:`dot notation`.
133
-
134
-
135
-
136
- * - ``uniqueDocs``
137
-
138
- - boolean
139
-
140
- - Optional. If this value is ``true``, the query returns a matching document once,
141
- even if more than one of the document's location fields match the
142
- query.
143
-
144
- .. include:: /includes/deprecation-uniqueDocs.rst
145
-
146
-
147
-
148
- * - ``minDistance``
149
-
150
- - number
151
-
152
- - Optional. The minimum distance from the center point that the documents can
153
- be. MongoDB limits the results to those documents that fall outside
154
- the specified distance from the center point.
155
-
156
- Specify the distance in meters for GeoJSON data and in radians for
157
- legacy coordinate pairs.
158
-
159
- .. versionadded:: 3.2
160
-
161
-
162
-
75
+
163
76
* - ``key``
164
-
77
+
165
78
-
166
-
79
+
167
80
- Optional. Specify the geospatial indexed field to use when calculating the
168
81
distance.
169
-
82
+
170
83
If your collection has multiple ``2d`` and/or multiple ``2dsphere``
171
84
indexes, you **must** use the ``key`` option to specify the indexed
172
85
field path to use. :ref:`pipeline-geoNear-key-param-example`
173
86
provides a full example.
174
-
87
+
175
88
If there is more than one ``2d`` index or more than one ``2dsphere``
176
89
index and you do not specify a ``key``, MongoDB will return an error.
177
-
90
+
178
91
If you do not specify the ``key``, and you have at most only one
179
92
``2d`` index and/or only one ``2dsphere`` index, MongoDB looks first
180
93
for a ``2d`` index to use. If a ``2d`` index does not exists, then
181
94
MongoDB looks for a ``2dsphere`` index to use.
182
-
95
+
183
96
.. versionadded:: 4.0
97
+
98
+ * - ``maxDistance``
99
+
100
+ - number
101
+
102
+ - Optional. The maximum distance from the center point that the documents *can*
103
+ be. MongoDB limits the results to those documents that fall within
104
+ the specified distance from the center point.
105
+
106
+ Specify the distance in meters if the specified point is
107
+ :term:`GeoJSON` and in radians if the specified point is
108
+ :term:`legacy coordinate pairs <legacy coordinate pairs>`.
109
+
110
+
111
+ * - ``minDistance``
112
+
113
+ - number
114
+
115
+ - Optional. The minimum distance from the center point that the documents *can*
116
+ be. MongoDB limits the results to those documents that fall outside
117
+ the specified distance from the center point.
118
+
119
+ Specify the distance in meters for GeoJSON data and in radians for
120
+ legacy coordinate pairs.
121
+
122
+ .. versionadded:: 3.2
123
+
124
+ * - ``near``
125
+
126
+ - GeoJSON point or :term:`legacy coordinate pair <legacy coordinate pairs>`
127
+
128
+ - The point for which to find the closest documents.
129
+
130
+ If using a :doc:`2dsphere </core/2dsphere>` index, you can specify
131
+ the point as either a GeoJSON point or legacy coordinate pair.
132
+
133
+ If using a :doc:`2d </core/2d>` index, specify the point as a legacy
134
+ coordinate pair.
135
+
136
+ * - ``query``
137
+
138
+ - document
139
+
140
+ - Optional. Limits the results to the documents that match the query. The query
141
+ syntax is the usual MongoDB :ref:`read operation query
142
+ <read-operations-query-argument>` syntax.
143
+
144
+ .. include:: /includes/fact-geoNear-restrict-near-in-query.rst
145
+
146
+
147
+ * - ``spherical``
148
+
149
+ - boolean
150
+
151
+ - Optional. Determines how MongoDB calculates the distance between two points:
152
+
153
+ - When ``true``, MongoDB uses :query:`$nearSphere` semantics and
154
+ calculates distances using spherical geometry.
155
+
156
+ - When ``false``, MongoDB uses :query:`$near` semantics:
157
+ spherical geometry for :doc:`2dsphere </core/2dsphere>`
158
+ indexes and planar geometry for :doc:`2d </core/2d>` indexes.
159
+
160
+ *Default: false.*
161
+
162
+
163
+ * - ``uniqueDocs``
164
+
165
+ - boolean
166
+
167
+ - Optional. If this value is ``true``, the query returns a matching document once,
168
+ even if more than one of the document's location fields match the
169
+ query.
170
+
171
+ .. include:: /includes/deprecation-uniqueDocs.rst
172
+
173
+
184
174
185
175
186
176
0 commit comments