Sorry - now I'm confused - My understanding is that if you want to drop an index by name, you simply have to refer to the name (
https://jira.mongodb.org/browse/SERVER-1887). It appears that doesn't work (or my syntax is incorrect? All the docs refer to this syntax: db.mycol.droIndex("theindexname"); ). Dropping by key does work
Here's a quick test:
> db.mytest.insert({myname: "somevalue", myid: 1});
> db.mytest.insert({myname: "someothervalue", myid: 2});
> db.mytest.ensureIndex({myname:1},{name:"myindexname"})
> db.mytest.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "mydb.mytest",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"myname" : 1
},
"ns" : "mydb.mytest",
"name" : "myindexname"
}
]
> db.mytest.dropIndex({"myindexname"});
Mon Feb 18 09:04:10.045 compile error: SyntaxError: Unexpected token } (shell):1
> db.mytest.dropIndex({"myname":1});
{ "nIndexesWas" : 2, "ok" : 1 }
The new text index feature indicates that id you want to drop a text index, you must refer to it by name (
http://docs.mongodb.org/manual/release-notes/2.4/#text-indexes).
Am I missing something?