Skip to content

Commit

Permalink
PYTHON-2219 Document hidden index option (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantmital authored Jul 29, 2020
1 parent c92150d commit de1e293
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
27 changes: 16 additions & 11 deletions pymongo/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1985,8 +1985,9 @@ def create_index(self, keys, session=None, **kwargs):
- `name`: custom name to use for this index - if none is
given, a name will be generated.
- `unique`: if ``True`` creates a uniqueness constraint on the index.
- `background`: if ``True`` this index should be created in the
- `unique`: if ``True``, creates a uniqueness constraint on the
index.
- `background`: if ``True``, this index should be created in the
background.
- `sparse`: if ``True``, omit from the index any documents that lack
the indexed field.
Expand All @@ -2002,13 +2003,15 @@ def create_index(self, keys, session=None, **kwargs):
this collection after <int> seconds. The indexed field must
be a UTC datetime or the data will not expire.
- `partialFilterExpression`: A document that specifies a filter for
a partial index. Requires server version >=3.2.
a partial index. Requires MongoDB >=3.2.
- `collation` (optional): An instance of
:class:`~pymongo.collation.Collation`. This option is only supported
on MongoDB 3.4 and above.
:class:`~pymongo.collation.Collation`. Requires MongoDB >= 3.4.
- `wildcardProjection`: Allows users to include or exclude specific
field paths from a `wildcard index`_ using the { "$**" : 1} key
pattern. Requires server version >= 4.2.
field paths from a `wildcard index`_ using the {"$**" : 1} key
pattern. Requires MongoDB >= 4.2.
- `hidden`: if ``True``, this index will be hidden from the query
planner and will not be evaluated as part of query plan
selection. Requires MongoDB >= 4.4.
See the MongoDB documentation for a full list of supported options by
server version.
Expand All @@ -2030,18 +2033,20 @@ def create_index(self, keys, session=None, **kwargs):
options (see the above list) should be passed as keyword
arguments
.. versionchanged:: 3.11
Added the ``hidden`` option.
.. versionchanged:: 3.6
Added ``session`` parameter. Added support for passing maxTimeMS
in kwargs.
.. versionchanged:: 3.4
Apply this collection's write concern automatically to this operation
when connected to MongoDB >= 3.4. Support the `collation` option.
.. versionchanged:: 3.2
Added partialFilterExpression to support partial indexes.
Added partialFilterExpression to support partial indexes.
.. versionchanged:: 3.0
Renamed `key_or_list` to `keys`. Removed the `cache_for` option.
:meth:`create_index` no longer caches index names. Removed support
for the drop_dups and bucket_size aliases.
Renamed `key_or_list` to `keys`. Removed the `cache_for` option.
:meth:`create_index` no longer caches index names. Removed support
for the drop_dups and bucket_size aliases.
.. mongodoc:: indexes
Expand Down
16 changes: 11 additions & 5 deletions pymongo/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ def __init__(self, keys, **kwargs):
- `name`: custom name to use for this index - if none is
given, a name will be generated.
- `unique`: if ``True`` creates a uniqueness constraint on the index.
- `background`: if ``True`` this index should be created in the
- `unique`: if ``True``, creates a uniqueness constraint on the index.
- `background`: if ``True``, this index should be created in the
background.
- `sparse`: if ``True``, omit from the index any documents that lack
the indexed field.
Expand All @@ -407,12 +407,15 @@ def __init__(self, keys, **kwargs):
this collection after <int> seconds. The indexed field must
be a UTC datetime or the data will not expire.
- `partialFilterExpression`: A document that specifies a filter for
a partial index. Requires server version >= 3.2.
a partial index. Requires MongoDB >= 3.2.
- `collation`: An instance of :class:`~pymongo.collation.Collation`
that specifies the collation to use in MongoDB >= 3.4.
- `wildcardProjection`: Allows users to include or exclude specific
field paths from a `wildcard index`_ using the { "$**" : 1} key
pattern. Requires server version >= 4.2.
pattern. Requires MongoDB >= 4.2.
- `hidden`: if ``True``, this index will be hidden from the query
planner and will not be evaluated as part of query plan
selection. Requires MongoDB >= 4.4.
See the MongoDB documentation for a full list of supported options by
server version.
Expand All @@ -424,8 +427,11 @@ def __init__(self, keys, **kwargs):
options (see the above list) should be passed as keyword
arguments
.. versionchanged:: 3.11
Added the ``hidden`` option.
.. versionchanged:: 3.2
Added partialFilterExpression to support partial indexes.
Added the ``partialFilterExpression`` option to support partial
indexes.
.. _wildcard index: https://docs.mongodb.com/master/core/index-wildcard/#wildcard-index-core
"""
Expand Down

0 comments on commit de1e293

Please sign in to comment.