Skip to content

Commit de1e293

Browse files
PYTHON-2219 Document hidden index option (#474)
1 parent c92150d commit de1e293

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

pymongo/collection.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -1985,8 +1985,9 @@ def create_index(self, keys, session=None, **kwargs):
19851985
19861986
- `name`: custom name to use for this index - if none is
19871987
given, a name will be generated.
1988-
- `unique`: if ``True`` creates a uniqueness constraint on the index.
1989-
- `background`: if ``True`` this index should be created in the
1988+
- `unique`: if ``True``, creates a uniqueness constraint on the
1989+
index.
1990+
- `background`: if ``True``, this index should be created in the
19901991
background.
19911992
- `sparse`: if ``True``, omit from the index any documents that lack
19921993
the indexed field.
@@ -2002,13 +2003,15 @@ def create_index(self, keys, session=None, **kwargs):
20022003
this collection after <int> seconds. The indexed field must
20032004
be a UTC datetime or the data will not expire.
20042005
- `partialFilterExpression`: A document that specifies a filter for
2005-
a partial index. Requires server version >=3.2.
2006+
a partial index. Requires MongoDB >=3.2.
20062007
- `collation` (optional): An instance of
2007-
:class:`~pymongo.collation.Collation`. This option is only supported
2008-
on MongoDB 3.4 and above.
2008+
:class:`~pymongo.collation.Collation`. Requires MongoDB >= 3.4.
20092009
- `wildcardProjection`: Allows users to include or exclude specific
2010-
field paths from a `wildcard index`_ using the { "$**" : 1} key
2011-
pattern. Requires server version >= 4.2.
2010+
field paths from a `wildcard index`_ using the {"$**" : 1} key
2011+
pattern. Requires MongoDB >= 4.2.
2012+
- `hidden`: if ``True``, this index will be hidden from the query
2013+
planner and will not be evaluated as part of query plan
2014+
selection. Requires MongoDB >= 4.4.
20122015
20132016
See the MongoDB documentation for a full list of supported options by
20142017
server version.
@@ -2030,18 +2033,20 @@ def create_index(self, keys, session=None, **kwargs):
20302033
options (see the above list) should be passed as keyword
20312034
arguments
20322035
2036+
.. versionchanged:: 3.11
2037+
Added the ``hidden`` option.
20332038
.. versionchanged:: 3.6
20342039
Added ``session`` parameter. Added support for passing maxTimeMS
20352040
in kwargs.
20362041
.. versionchanged:: 3.4
20372042
Apply this collection's write concern automatically to this operation
20382043
when connected to MongoDB >= 3.4. Support the `collation` option.
20392044
.. versionchanged:: 3.2
2040-
Added partialFilterExpression to support partial indexes.
2045+
Added partialFilterExpression to support partial indexes.
20412046
.. versionchanged:: 3.0
2042-
Renamed `key_or_list` to `keys`. Removed the `cache_for` option.
2043-
:meth:`create_index` no longer caches index names. Removed support
2044-
for the drop_dups and bucket_size aliases.
2047+
Renamed `key_or_list` to `keys`. Removed the `cache_for` option.
2048+
:meth:`create_index` no longer caches index names. Removed support
2049+
for the drop_dups and bucket_size aliases.
20452050
20462051
.. mongodoc:: indexes
20472052

pymongo/operations.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,8 @@ def __init__(self, keys, **kwargs):
390390
391391
- `name`: custom name to use for this index - if none is
392392
given, a name will be generated.
393-
- `unique`: if ``True`` creates a uniqueness constraint on the index.
394-
- `background`: if ``True`` this index should be created in the
393+
- `unique`: if ``True``, creates a uniqueness constraint on the index.
394+
- `background`: if ``True``, this index should be created in the
395395
background.
396396
- `sparse`: if ``True``, omit from the index any documents that lack
397397
the indexed field.
@@ -407,12 +407,15 @@ def __init__(self, keys, **kwargs):
407407
this collection after <int> seconds. The indexed field must
408408
be a UTC datetime or the data will not expire.
409409
- `partialFilterExpression`: A document that specifies a filter for
410-
a partial index. Requires server version >= 3.2.
410+
a partial index. Requires MongoDB >= 3.2.
411411
- `collation`: An instance of :class:`~pymongo.collation.Collation`
412412
that specifies the collation to use in MongoDB >= 3.4.
413413
- `wildcardProjection`: Allows users to include or exclude specific
414414
field paths from a `wildcard index`_ using the { "$**" : 1} key
415-
pattern. Requires server version >= 4.2.
415+
pattern. Requires MongoDB >= 4.2.
416+
- `hidden`: if ``True``, this index will be hidden from the query
417+
planner and will not be evaluated as part of query plan
418+
selection. Requires MongoDB >= 4.4.
416419
417420
See the MongoDB documentation for a full list of supported options by
418421
server version.
@@ -424,8 +427,11 @@ def __init__(self, keys, **kwargs):
424427
options (see the above list) should be passed as keyword
425428
arguments
426429
430+
.. versionchanged:: 3.11
431+
Added the ``hidden`` option.
427432
.. versionchanged:: 3.2
428-
Added partialFilterExpression to support partial indexes.
433+
Added the ``partialFilterExpression`` option to support partial
434+
indexes.
429435
430436
.. _wildcard index: https://docs.mongodb.com/master/core/index-wildcard/#wildcard-index-core
431437
"""

0 commit comments

Comments
 (0)