I want to create Index by ensureIndex at name with parameter:dropDups,cause my collection books has two documents' name is "0book".
db.books.ensureIndex({name:1},{unique:true,dropDups:true})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"errmsg" : "exception: E11000 duplicate key error index:
foobar.books.$name_1 dup key: { : \"0book\" }",
"code" : 11000,
"ok" : 0
}
Otherwise,it alerts me to the errmsg as above.
I don't know how to use pramater "dropDups",when create index in mongodb