Skip to content

Commit d02352c

Browse files
committed
Improvements to ensure/create_index docs PYTHON-657
1 parent 3ebb4b2 commit d02352c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pymongo/collection.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,10 @@ def create_index(self, key_or_list, cache_for=300, **kwargs):
942942
943943
Takes either a single key or a list of (key, direction) pairs.
944944
The key(s) must be an instance of :class:`basestring`
945-
(:class:`str` in python 3), and the directions must be one of
945+
(:class:`str` in python 3), and the direction(s) must be one of
946946
(:data:`~pymongo.ASCENDING`, :data:`~pymongo.DESCENDING`,
947-
:data:`~pymongo.GEO2D`). Returns the name of the created index.
947+
:data:`~pymongo.GEO2D`, :data:`~pymongo.GEOHAYSTACK`,
948+
:data:`~pymongo.GEOSPHERE`, :data:`~pymongo.HASHED`).
948949
949950
To create a single key index on the key ``'mike'`` we just use
950951
a string argument:
@@ -1058,8 +1059,9 @@ def ensure_index(self, key_or_list, cache_for=300, **kwargs):
10581059
The key(s) must be an instance of :class:`basestring`
10591060
(:class:`str` in python 3), and the direction(s) must be one of
10601061
(:data:`~pymongo.ASCENDING`, :data:`~pymongo.DESCENDING`,
1061-
:data:`~pymongo.GEO2D`). See :meth:`create_index` for a detailed
1062-
example.
1062+
:data:`~pymongo.GEO2D`, :data:`~pymongo.GEOHAYSTACK`,
1063+
:data:`~pymongo.GEOSPHERE`, :data:`~pymongo.HASHED`).
1064+
See :meth:`create_index` for a detailed example.
10631065
10641066
Unlike :meth:`create_index`, which attempts to create an index
10651067
unconditionally, :meth:`ensure_index` takes advantage of some
@@ -1076,8 +1078,9 @@ def ensure_index(self, key_or_list, cache_for=300, **kwargs):
10761078
:meth:`ensure_index` within the cache window will fail to
10771079
re-create the missing index.
10781080
1079-
Returns the name of the created index if an index is actually
1080-
created. Returns ``None`` if the index already exists.
1081+
Returns the specified or generated index name used if
1082+
:meth:`ensure_index` attempts to create the index. Returns
1083+
``None`` if the index is already cached.
10811084
10821085
All optional index creation parameters should be passed as
10831086
keyword arguments to this method. Valid options include:

0 commit comments

Comments
 (0)