-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.0.0, 3.0.1
-
Component/s: Index Maintenance
-
None
-
ALL
-
- Open MongoDB Shell
- Switch to database `mydb`
- Insert `{x: 1}` into collection `testData`
- Create index on key `x` of collection `testData`, specifying option `{unique: true, dropDups: true}`
When attempting to create a unique index on a key with duplicates (i.e. using the `dropDups: true` option), the index creation fails with a duplicate key error.
MongoDB shell version: 3.0.1
connecting to: test > use mydb switched to db mydb > db.testData.insert({x: 1}) WriteResult({ "nInserted" : 1 }) > db.testData.insert({x: 1}) WriteResult({ "nInserted" : 1 }) > db.testData.createIndex({x: 1}, {unique: true, dropDups: true}) { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "errmsg" : "exception: E11000 duplicate key error index: mydb.testData.$x_1 dup key: { : 1.0 }", "code" : 11000, "ok" : 0 }
- duplicates
-
SERVER-17599 dropDups ignored on index creation
- Closed