Skip to content

Commit 826cc50

Browse files
committed
PYTHON-1789 Update indexing docs for wildcard index options
1 parent 26d25cd commit 826cc50

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

pymongo/collection.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,10 +1931,13 @@ def create_index(self, keys, session=None, **kwargs):
19311931
this collection after <int> seconds. The indexed field must
19321932
be a UTC datetime or the data will not expire.
19331933
- `partialFilterExpression`: A document that specifies a filter for
1934-
a partial index.
1934+
a partial index. Requires server version >=3.2.
19351935
- `collation` (optional): An instance of
19361936
:class:`~pymongo.collation.Collation`. This option is only supported
19371937
on MongoDB 3.4 and above.
1938+
- `wildcardProjection`: Allows users to include or exclude specific
1939+
field paths from a `wildcard index`_ using the { "$**" : 1} key
1940+
pattern. Requires server version >= 4.2.
19381941
19391942
See the MongoDB documentation for a full list of supported options by
19401943
server version.
@@ -1943,8 +1946,6 @@ def create_index(self, keys, session=None, **kwargs):
19431946
option is silently ignored by the server and unique index builds
19441947
using the option will fail if a duplicate value is detected.
19451948
1946-
.. note:: `partialFilterExpression` requires server version **>= 3.2**
1947-
19481949
.. note:: The :attr:`~pymongo.collection.Collection.write_concern` of
19491950
this collection is automatically applied to this operation when using
19501951
MongoDB >= 3.4.
@@ -1972,6 +1973,8 @@ def create_index(self, keys, session=None, **kwargs):
19721973
for the drop_dups and bucket_size aliases.
19731974
19741975
.. mongodoc:: indexes
1976+
1977+
.. _wildcard index: https://docs.mongodb.com/master/core/index-wildcard/#wildcard-index-core
19751978
"""
19761979
keys = helpers._index_list(keys)
19771980
name = kwargs.setdefault("name", helpers._gen_index_name(keys))

pymongo/operations.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,16 @@ def __init__(self, keys, **kwargs):
338338
this collection after <int> seconds. The indexed field must
339339
be a UTC datetime or the data will not expire.
340340
- `partialFilterExpression`: A document that specifies a filter for
341-
a partial index.
341+
a partial index. Requires server version >= 3.2.
342342
- `collation`: An instance of :class:`~pymongo.collation.Collation`
343343
that specifies the collation to use in MongoDB >= 3.4.
344+
- `wildcardProjection`: Allows users to include or exclude specific
345+
field paths from a `wildcard index`_ using the { "$**" : 1} key
346+
pattern. Requires server version >= 4.2.
344347
345348
See the MongoDB documentation for a full list of supported options by
346349
server version.
347350
348-
.. note:: `partialFilterExpression` requires server version **>= 3.2**
349-
350351
:Parameters:
351352
- `keys`: a single key or a list of (key, direction)
352353
pairs specifying the index to create
@@ -356,6 +357,8 @@ def __init__(self, keys, **kwargs):
356357
357358
.. versionchanged:: 3.2
358359
Added partialFilterExpression to support partial indexes.
360+
361+
.. _wildcard index: https://docs.mongodb.com/master/core/index-wildcard/#wildcard-index-core
359362
"""
360363
keys = _index_list(keys)
361364
if "name" not in kwargs:

0 commit comments

Comments
 (0)