MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / drop_indexes

Method drop_indexes

pymongo/synchronous/collection.py:2393–2424  ·  view source on GitHub ↗

Drops all indexes on this collection. Can be used on non-existent collections or collections with no indexes. Raises OperationFailure on an error. :param session: a :class:`~pymongo.client_session.ClientSession`. :param comment: A user-provided comment t

(
        self,
        session: Optional[ClientSession] = None,
        comment: Optional[Any] = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

2391 return (self._create_indexes([index], session, **cmd_options))[0]
2392
2393 def drop_indexes(
2394 self,
2395 session: Optional[ClientSession] = None,
2396 comment: Optional[Any] = None,
2397 **kwargs: Any,
2398 ) -> None:
2399 """Drops all indexes on this collection.
2400
2401 Can be used on non-existent collections or collections with no indexes.
2402 Raises OperationFailure on an error.
2403
2404 :param session: a
2405 :class:`~pymongo.client_session.ClientSession`.
2406 :param comment: A user-provided comment to attach to this
2407 command.
2408 :param kwargs: optional arguments to the createIndexes
2409 command (like maxTimeMS) can be passed as keyword arguments.
2410
2411 .. note:: The :attr:`~pymongo.collection.Collection.write_concern` of
2412 this collection is automatically applied to this operation.
2413
2414 .. versionchanged:: 3.6
2415 Added ``session`` parameter. Added support for arbitrary keyword
2416 arguments.
2417
2418 .. versionchanged:: 3.4
2419 Apply this collection's write concern automatically to this operation
2420 when connected to MongoDB >= 3.4.
2421 """
2422 if comment is not None:
2423 kwargs["comment"] = comment
2424 self._drop_index("*", session=session, **kwargs)
2425
2426 def drop_index(
2427 self,

Callers 15

cleanup_collsMethod · 0.45
test_writesMethod · 0.45
test_create_indexesMethod · 0.45
test_create_indexMethod · 0.45
test_drop_indexMethod · 0.45
test_index_geo2dMethod · 0.45
test_index_textMethod · 0.45
test_index_2dsphereMethod · 0.45
test_index_hashedMethod · 0.45
test_index_sparseMethod · 0.45

Calls 1

_drop_indexMethod · 0.95

Tested by 15

test_writesMethod · 0.36
test_create_indexesMethod · 0.36
test_create_indexMethod · 0.36
test_drop_indexMethod · 0.36
test_index_geo2dMethod · 0.36
test_index_textMethod · 0.36
test_index_2dsphereMethod · 0.36
test_index_hashedMethod · 0.36
test_index_sparseMethod · 0.36
test_index_backgroundMethod · 0.36