Drops the specified index on this collection. Can be used on non-existent collections or collections with no indexes. Raises OperationFailure on an error (e.g. trying to drop an index that does not exist). `index_or_name` can be either an index name (as returned by
(
self,
index_or_name: _IndexKeyHint,
session: Optional[ClientSession] = None,
comment: Optional[Any] = None,
**kwargs: Any,
)
| 2424 | self._drop_index("*", session=session, **kwargs) |
| 2425 | |
| 2426 | def drop_index( |
| 2427 | self, |
| 2428 | index_or_name: _IndexKeyHint, |
| 2429 | session: Optional[ClientSession] = None, |
| 2430 | comment: Optional[Any] = None, |
| 2431 | **kwargs: Any, |
| 2432 | ) -> None: |
| 2433 | """Drops the specified index on this collection. |
| 2434 | |
| 2435 | Can be used on non-existent collections or collections with no |
| 2436 | indexes. Raises OperationFailure on an error (e.g. trying to |
| 2437 | drop an index that does not exist). `index_or_name` |
| 2438 | can be either an index name (as returned by `create_index`), |
| 2439 | or an index specifier (as passed to `create_index`). An index |
| 2440 | specifier should be a list of (key, direction) pairs. Raises |
| 2441 | TypeError if index is not an instance of (str, unicode, list). |
| 2442 | |
| 2443 | .. warning:: |
| 2444 | |
| 2445 | if a custom name was used on index creation (by |
| 2446 | passing the `name` parameter to :meth:`create_index`) the index |
| 2447 | **must** be dropped by name. |
| 2448 | |
| 2449 | :param index_or_name: index (or name of index) to drop |
| 2450 | :param session: a |
| 2451 | :class:`~pymongo.client_session.ClientSession`. |
| 2452 | :param comment: A user-provided comment to attach to this |
| 2453 | command. |
| 2454 | :param kwargs: optional arguments to the createIndexes |
| 2455 | command (like maxTimeMS) can be passed as keyword arguments. |
| 2456 | |
| 2457 | |
| 2458 | |
| 2459 | .. note:: The :attr:`~pymongo.collection.Collection.write_concern` of |
| 2460 | this collection is automatically applied to this operation. |
| 2461 | |
| 2462 | |
| 2463 | .. versionchanged:: 3.6 |
| 2464 | Added ``session`` parameter. Added support for arbitrary keyword |
| 2465 | arguments. |
| 2466 | |
| 2467 | .. versionchanged:: 3.4 |
| 2468 | Apply this collection's write concern automatically to this operation |
| 2469 | when connected to MongoDB >= 3.4. |
| 2470 | |
| 2471 | """ |
| 2472 | self._drop_index(index_or_name, session, comment, **kwargs) |
| 2473 | |
| 2474 | @_csot.apply |
| 2475 | def _drop_index( |