27 IndexNotFound: Index not found(未找到索引)
MongoDB含义
在集合上未找到所引用的索引。通常在试图删除或重命名不存在的索引时出现。
原因
在 dropIndex/hideIndex 等命令中给出了错误的索引名或键规范;索引之前已被删除;或自动生成的索引名与预期不同(MongoDB 生成类似 field_1_field2_-1 的名称)。
解决方法
列出现有索引及其确切名称:db.my_collection.getIndexes()。用正确的名称或键文档重复操作:db.my_collection.dropIndex({field: 1}) 或 db.my_collection.dropIndex('field_1')。编写删除脚本时,使其在索引不存在时不会失败(加入存在性检查)。
同一数据库的其他条目
- 11601 InterruptedOperation was interrupted(操作被中断)
- 85 IndexOptionsConflictIndex already exists with different options / different name(索引已存在但选项不同/名称不同)
- 67 CannotCreateIndexCannot create index(无法创建索引)
- 79 UnknownReplWriteConcernUnknown replica set write concern(未知的副本集写关注)
- 10107 NotWritablePrimarynot master / not writable primary(不是 master / 不是可写的主节点)
- 91 ShutdownInProgressThe server is in the process of shutting down(服务器正在关闭)
- 189 PrimarySteppedDownPrimary stepped down while operation was in progress(操作进行期间主节点已降级)