text: MongoDB with drivers
  This page documents a mongosh
  method. To see the equivalent
  method in a MongoDB driver, see the corresponding page for your
  Drops the specified index or indexes (except the index on the
  field and the last remaining shard key index) from a collection.You can use the method to:
  Drop all but the
  index from a collection.db.collection.dropIndexes() Drop a specified index from a collection. To specify the index, you can pass the method either:
  Drop specified indexes from a collection. To specify multiple indexes to drop, pass the method an array of index names:
  db.collection.dropIndexes( [ "a_1_b_1", "a_1", "a_1__id_-1" ] ) If the array of index names includes a non-existent index, the method errors without dropping any of the specified indexes.
  To get the names of the indexes, use the
  method takes the following optional parameter:ParameterTypeDescriptionindexes
  string or document or array of strings
  Optional. Specifies the index or indexes to drop.
  To drop all but the _id index from the collection, omit the parameter.
  To drop a single index, specify either the index name, the index specification document (unless the index is a text index), or an array of the index name. To drop a text index, specify the index name or an array of the index name instead of the index specification document.
  To drop multiple indexes, specify an array of the index names.
  This method is available in deployments hosted in the following environments:
  MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
  This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
  Starting in MongoDB 6.0, db.collection.dropIndexes()
  raises an error if you attempt
  to use it to remove the last remaining shard key compatible index.
  drops all indexes except
  index and the last remaining shard key compatible index,
  if one exists.
  Starting in MongoDB 5.2, you can use db.collection.dropIndexes()
  to drop existing
  indexes on the same collection even if there is a build in progress on
  another index. In earlier versions, attempting to drop a different
  index during an in-progress index build results in a
  obtains an exclusive lock on the specified collection
  for the duration of the operation. All subsequent operations on the
  collection must wait until db.collection.dropIndexes()
  If the method is passed an array of index names that includes a non-existent index, the method errors without dropping any of the specified indexes.
  You cannot drop the default index on the _id
  To drop a text index, specify the index name instead of the index specification document.
  If an index specified to db.collection.dropIndexes()
  is still building, db.collection.dropIndexes()
  to stop the in-progress build. Stopping an index build has the same effect as
  dropping the built index.
  For replica sets, run db.collection.dropIndexes()
  on the primary.
  The primary stops the index build and creates an associated
  "abortIndexBuild" oplog entry. Secondaries which replicate
  the "abortIndexBuild" oplog entry stop the in-progress index build and
  discard the build job. See Index Build Process for detailed
  documentation on the index build process.
  MongoDB offers the ability to hide or unhide indexes from the query planner. By hiding an index from the planner, you can evaluate the potential impact of dropping an index without actually dropping the index.
  If after the evaluation, the user decides to drop the index, you can drop the hidden index; i.e. you do not need to unhide it first to drop it.
  If, however, the impact is negative, the user can unhide the index instead of having to recreate a dropped index. And because indexes are fully maintained while hidden, the indexes are immediately available for use once unhidden.
  For more information on hidden indexes, see Hidden Indexes.