|
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
|
}
|
|