Details
Description
Problem:
If an index is created with a name, then dropIndex will fail to drop the index. However, runCommand(
Reproduce:
Do the following
> db.journeys.save( {type :1, tm_uuid:2} )
|
> db.journeys.ensureIndex({type:1, tm_uuid:1}, {name:"Type TM-UUID"});
|
|
|
> db.journeys.getIndexes()
|
[
|
{
|
"name" : "_id_",
|
"ns" : "test.journeys",
|
"key" : {
|
"_id" : 1
|
}
|
},
|
{
|
"_id" : ObjectId("4cab0f09f29d24000f38d92f"),
|
"ns" : "test.journeys",
|
"key" : {
|
"type" : 1,
|
"tm_uuid" : 1
|
},
|
"name" : "Type TM-UUID"
|
}
|
]
|
|
|
|
|
> db.journeys.dropIndex({name:"Type TM-UUID"});
|
{ "errmsg" : "index not found", "ok" : 0 }
|
|
|
|
|
> db.runCommand({dropIndexes:'journeys', index : {type:1,tm_uuid:1}})
|
{ "nIndexesWas" : 2, "ok" : 1 }
|
|
|
|
|
> db.journeys.getIndexes()
|
[
|
{
|
"name" : "_id_",
|
"ns" : "test.journeys",
|
"key" : {
|
"_id" : 1
|
}
|
}
|
]
|
Workaround:
Use db.runCommand({dropIndexes...}
) to drop a index with a name.
Business Case:
User Expereince
Attachments
Issue Links
- related to
-
DOCS-596 dropIndex() by index name is not mentioned in wiki.
-
- Closed
-