Definition定义
db.collection.dropSearchIndex()
New in version 7.0.在版本7.0中新增。 (Also available starting in 6.0.7从6.0.7开始也可用)
Deletes an existing MongoDB Search index or Vector Search index.删除现有的MongoDB搜索索引或矢量搜索索引。
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.mongosh方法。这不是数据库命令或特定语言驱动程序(如Node.js)的文档。
For the database command, see the 关于数据库命令,请参阅dropSearchIndex command.dropSearchIndex命令。
For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.有关MongoDB API驱动程序,请参阅特定语言的MongoDB驱动程序文档。
Compatibility兼容性
This method is available in deployments hosted in the following environments:此方法在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
Important
This command is not supported in serverless instances. For more information, see Unsupported Commands.无服务器实例不支持此命令。有关详细信息,请参阅不支持的命令。
Syntax语法
Command syntax:命令语法:
db.<collection>.dropSearchIndex(<name>)Command Fields命令字段
dropSearchIndex() takes the following field:取以下字段:
name |
Behavior行为
After you run 运行dropSearchIndex(), there may be a delay between when you receive a response from the command and when the index is deleted.dropSearchIndex()后,从收到命令的响应到删除索引之间可能会有延迟。
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.$listSearchIndexes聚合阶段。删除索引后,该索引将不再出现在$listSearchIndexes输出中。
Access Control访问控制
If your deployment enforces access control, the user running the 如果部署强制执行访问控制,则运行dropSearchIndex() method must have the dropSearchIndex privilege action on the database:dropSearchIndex()方法的用户必须对数据库具有dropSearchIndex权限操作:
{ resource: { database : true }, actions: [ "dropSearchIndex" ] }
The built-in 内置的dbAdmin and readWrite roles provide the dropSearchIndex privilege. dbAdmin和readWrite角色提供dropSearchIndex权限。The following example grants the 以下示例授予readWrite role on the qa database:qa数据库上的readWrite角色:
db.grantRolesToUser(
"<user>",
[ { role: "readWrite", db: "qa" } ]
)Example示例
The following example deletes a search index named 以下示例删除searchIndex01 on the movies collection:movies集合上名为searchIndex01的搜索索引:
db.movies.dropSearchIndex("searchIndex01")