@@ -47,16 +47,17 @@ following form:
47
47
48
48
.. code-block:: javascript
49
49
50
- db.places.find( { loc: {$near: [-70,40 ] } })
50
+ db.places.find( { loc: { $near: [ -70, 40 ] } } )
51
51
52
52
returns output similar to the following:
53
53
54
54
.. code-block:: javascript
55
55
56
- { "_id" : ObjectId(" ... "), "loc" : [ -73, 40 ] }
56
+ { "_id" : ObjectId(" ... "), "loc" : [ -73, 39 ] }
57
57
58
58
The :dbcommand:`geoNear` command returns more information than does the
59
- :operator:`$near` operator but does not sort results. The
59
+ :operator:`$near` operator. The :dbcommand:`geoNear` command can only
60
+ return a single 16-megabyte result set. The
60
61
:dbcommand:`geoNear` command also offers additional operators, such as
61
62
operators to query for :ref:`maximum <geospatial-indexes-distance>` or
62
63
:ref:`spherical <geospatial-indexes-spherical>` distance. For a list of
@@ -84,15 +85,14 @@ following form:
84
85
85
86
{
86
87
"ns" : "test.places",
87
- "near" : "0110000111111000000111111000000111111000000111111000",
88
88
"results" : [
89
89
{
90
90
"dis" : 3,
91
91
"obj" : {
92
92
"_id" : ObjectId(" ... "),
93
93
"loc" : [
94
94
-73,
95
- 40
95
+ 39
96
96
]
97
97
}
98
98
}
@@ -105,6 +105,7 @@ following form:
105
105
"avgDistance" : 3,
106
106
"maxDistance" : 3.0000188685220253
107
107
},
108
+ "near" : "0110000111111000000111111000000111111000000111111000",
108
109
"ok" : 1
109
110
}
110
111
@@ -124,14 +125,14 @@ method, use :operator:`$maxDistance` operator. Use the following form:
124
125
125
126
.. code-block:: javascript
126
127
127
- db.collection.find( { <location field>: { $near: [ x, y ] } , $maxDistance : z } )
128
+ db.collection.find( { <location field> : { $near : [ x , y ] , $maxDistance : <distance> } } )
128
129
129
130
To specify distance with the :dbcommand:`geoNear` command, use the
130
131
``maxDistance`` option. Use the following form:
131
132
132
133
.. code-block:: javascript
133
134
134
- db.runCommand( { geoNear: "collection", near: [ x, y ], maxDistance: z } )
135
+ db.runCommand( { geoNear: "collection", near: [ x, y ], maxDistance: <distance> } )
135
136
136
137
.. _geospatial-indexes-limit:
137
138
@@ -140,9 +141,7 @@ Limit the Number of Results
140
141
141
142
By default, geospatial queries using :method:`find()
142
143
<db.collection.find()>` method return 100 documents, sorted by
143
- distance.
144
-
145
- To limit the result when using the :method:`find()
144
+ distance. To limit the result when using the :method:`find()
146
145
<db.collection.find()>` method, use the :method:`limit()
147
146
<cursor.limit()>` method, as in the following prototype:
148
147
@@ -151,30 +150,14 @@ To limit the result when using the :method:`find()
151
150
db.collection.find( { <location field>: { $near: [ x, y ] } } ).limit(<n>)
152
151
153
152
To limit the result set when using the :dbcommand:`geoNear` command, use
154
- the ``num`` option. The following is a prototype of the command :
153
+ the ``num`` option. Use the following form :
155
154
156
155
.. code-block:: javascript
157
156
158
157
db.runCommand( { geoNear: "collection", near: [ x, y ], num: z } )
159
158
160
- The :method:`limit() <cursor.limit()>` method and ``near`` parameter
161
- to :dbcommand:`geoNear` do not limit geospatial query results by
162
- distance, only the number of results. To limit geospatial search
163
- results by distance, please see the :ref:`geospatial-indexes-distance`
164
- section.
165
-
166
- .. note::
167
-
168
- The :method:`limit() <cursor.limit()>` method and ``num`` option have
169
- different performance characteristics. Geospatial queries using
170
- :method:`limit() <cursor.limit()>` method are slower than using
171
- :dbcommand:`geoNear`.
172
-
173
- Geospatial queries with the :method:`find() <db.collection.find()>`
174
- method will return 100 documents, sort them, and finally limit the
175
- result set. Geospatial queries with the :dbcommand:`geoNear` and
176
- ``num`` option will only return the specified number of unsorted
177
- documents.
159
+ To limit geospatial search results by distance, see
160
+ :ref:`geospatial-indexes-distance`.
178
161
179
162
.. _geospatial-indexes-within:
180
163
.. _geospatial-indexes-bounded:
0 commit comments