Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
3.0.0, 3.0.1
-
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}`
Description
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
|
}
|
Attachments
Issue Links
- duplicates
-
SERVER-17599 dropDups ignored on index creation
-
- Closed
-