85 IndexOptionsConflict: Index already exists with different options / different name
MongoDBWhat does it mean?
The index you are creating conflicts with an existing one: an index with the same name has different options, or an equivalent index with the same key and options already exists under another name. MongoDB does not let you re-create the same index with a conflicting definition.
Why does it happen?
Creating an index with the same name and key but different options (e.g. expireAfterSeconds, partialFilterExpression, collation); or redefining the equivalent of an existing index under a different name ('Index already exists with a different name'). Index definitions drifting over time in application/migration scripts is the typical cause. Same name with a different key gives 86 IndexKeySpecsConflict instead.
How to fix it
View the existing index: db.my_collection.getIndexes(). If you really want to change the options, drop the old index and create the new one: db.my_collection.dropIndex('index_name') then createIndex(...). Otherwise make the definition match the existing index exactly, or give the new index a different name. Make migration scripts idempotent.
More from this engine
- 20 IllegalOperationIllegal operation
- 48 NamespaceExistsNamespace (collection) already exists
- 11601 InterruptedOperation was interrupted
- 67 CannotCreateIndexCannot create index
- 27 IndexNotFoundIndex not found
- 79 UnknownReplWriteConcernUnknown replica set write concern
- 10107 NotWritablePrimarynot master / not writable primary