Skip to content

Commit 98ce687

Browse files
shreybatraShaneHarvey
authored andcommitted
Add GEOSPHERE to geospatial docs (mongodb#364)
Add warning for deprecated geoNear command.
1 parent 2a306ab commit 98ce687

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

doc/contributors.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ The following is a list of people who have contributed to
8383
- Zhecong Kwok (gzcf)
8484
- TaoBeier(tao12345666333)
8585
- Jagrut Trivedi(Jagrut)
86+
- Shrey Batra(shreybatra)

doc/examples/geo.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Geospatial Indexing Example
88
client.drop_database('geo_example')
99

1010
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.
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+
4345
Querying
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+
5862
The $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

Comments
 (0)