@@ -8,7 +8,7 @@ Geospatial Indexing Example
8
8
client.drop_database('geo_example')
9
9
10
10
This example shows how to create and use a :data: `~pymongo.GEO2D `
11
- index in PyMongo.
11
+ index in PyMongo. To create a spherical (earth-like) geospatial index use :data: ` ~pymongo.GEOSPHERE ` instead.
12
12
13
13
.. mongodoc :: geo
14
14
@@ -40,6 +40,8 @@ insert a couple of example locations:
40
40
>>> result.inserted_ids
41
41
[ObjectId('...'), ObjectId('...'), ObjectId('...'), ObjectId('...')]
42
42
43
+ .. note :: If specifying latitude and longitude coordinates in :data:`~pymongo.GEOSPHERE`, list the **longitude** first and then **latitude**.
44
+
43
45
Querying
44
46
--------
45
47
@@ -55,6 +57,8 @@ Using the geospatial index we can find documents near another point:
55
57
{u'_id': ObjectId('...'), u'loc': [4, 4]}
56
58
{u'_id': ObjectId('...'), u'loc': [1, 2]}
57
59
60
+ .. note :: If using :data:`pymongo.GEOSPHERE`, using $nearSphere is recommended.
61
+
58
62
The $maxDistance operator requires the use of :class: `~bson.son.SON `:
59
63
60
64
.. doctest ::
@@ -96,3 +100,9 @@ geoNear queries are also supported using :class:`~bson.son.SON`::
96
100
>>> from bson.son import SON
97
101
>>> db.command(SON([('geoNear', 'places'), ('near', [1, 2])]))
98
102
{u'ok': 1.0, u'stats': ...}
103
+
104
+ .. warning :: Starting in MongoDB version 4.0, MongoDB deprecates the **geoNear** command. Use one of the following operations instead.
105
+
106
+ * $geoNear - aggregation stage.
107
+ * $near - query operator.
108
+ * $nearSphere - query operator.
0 commit comments