@@ -8,7 +8,7 @@ Geospatial Indexing Example
88 client.drop_database('geo_example')
99
1010This 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.
1212
1313.. mongodoc :: geo
1414
@@ -40,6 +40,8 @@ insert a couple of example locations:
4040 >>> result.inserted_ids
4141 [ObjectId('...'), ObjectId('...'), ObjectId('...'), ObjectId('...')]
4242
43+ .. note :: If specifying latitude and longitude coordinates in :data:`~pymongo.GEOSPHERE`, list the **longitude** first and then **latitude**.
44+
4345Querying
4446--------
4547
@@ -55,6 +57,8 @@ Using the geospatial index we can find documents near another point:
5557 {u'_id': ObjectId('...'), u'loc': [4, 4]}
5658 {u'_id': ObjectId('...'), u'loc': [1, 2]}
5759
60+ .. note :: If using :data:`pymongo.GEOSPHERE`, using $nearSphere is recommended.
61+
5862The $maxDistance operator requires the use of :class: `~bson.son.SON `:
5963
6064.. doctest ::
@@ -96,3 +100,9 @@ geoNear queries are also supported using :class:`~bson.son.SON`::
96100 >>> from bson.son import SON
97101 >>> db.command(SON([('geoNear', 'places'), ('near', [1, 2])]))
98102 {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