Docs Menu

Docs HomeMongoDB Manual

db.collection.dropSearchIndex()

On this page

  • Definition
  • Syntax
  • Command Fields
  • Behavior
  • Access Control
  • Example
db.collection.dropSearchIndex()

Deletes an existing Atlas Search index.

Important

This command can only be run on a deployment hosted on MongoDB Atlas, and requires an Atlas cluster tier of at least M10.

Important

mongosh Method

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the dropSearchIndex command.

For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

mongo shell v4.4

Command syntax:

db.<collection>.dropSearchIndex(<name>)

dropSearchIndex() takes the following field:

Field
Type
Necessity
Description
name
string
Required
Name of the search index to drop.

After you run dropSearchIndex(), there may be a delay between when you receive a response from the command and when the index is deleted.

To see the status of your search indexes, use the $listSearchIndexes aggregation stage. Once your index is deleted, that index no longer appears in the $listSearchIndexes output.

If your deployment enforces access control, the user running the dropSearchIndex() method must have the dropSearchIndex privilege action on the database:

{ resource: { database : true }, actions: [ "dropSearchIndex" ] }

The built-in dbAdmin and readWrite roles provide the dropSearchIndex privilege. The following example grants the readWrite role on the qa database:

db.grantRolesToUser(
"<user>",
[ { role: "readWrite", db: "qa" } ]
)

The following example deletes a search index named searchIndex01 on the movies collection:

db.movies.dropSearchIndex("searchIndex01")
←  db.collection.createSearchIndex()db.collection.getSearchIndexes() →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.