how to delete these indexes of non exist collections?

257 views
Skip to first unread message

j...@avos.com

unread,
Jun 23, 2013, 11:52:33 PM6/23/13
to mongod...@googlegroups.com
Hi,
   I've met a stranger problem. I need to delete some indexes of non exist collections and the collections's name include character '$'.
   How coud I delete that in mongo shell ?

mongos> show collections
images.chunks
images.files
mainBodyHtmlContent
originalHTMLContent
system.indexes
mongos> db.system.index.find()
...
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "meiwei.${mongo.thumbnail}.files", "name" : "_id_" }
{ "v" : 1, "key" : { "filename" : 1, "uploadDate" : 1 }, "ns" : "meiwei.${mongo.thumbnail}.files", "name" : "filename_1_uploadDate_1" }
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "meiwei.${mongo.thumbnail}.chunks", "name" : "_id_" }
{ "v" : 1, "key" : { "files_id" : 1, "n" : 1 }, "ns" : "meiwei.${mongo.thumbnail}.chunks", "name" : "files_id_1_n_1" }
...


  I tried this , not work.
mongos> db.${mongo.thumbnail}.files.dropIndex( { "filename":1, "uploadDate":1 } )
Mon Jun 24 11:03:25.636 JavaScript execution failed: SyntaxError: Unexpected token {

mongos> db.\$\{mongo.thumbnail\}.files.dropIndexes( { "filename":1, "uploadDate":1 } )
Mon Jun 24 11:06:23.615 JavaScript execution failed: SyntaxError: Unexpected token ILLEGAL

  Any help?
  Thanks

-jwu

Asya Kamsky

unread,
Jun 25, 2013, 3:03:24 AM6/25/13
to mongod...@googlegroups.com
Use the syntax:

> db.getCollection("nameofcollectioninquotes").dropIndexes() etc.

Asya

j...@avos.com

unread,
Jun 25, 2013, 6:25:51 AM6/25/13
to mongod...@googlegroups.com
unfortunately, not work

mongos> db.getCollection("meiwei.${mongo.thumbnail}.files").dropIndexes()
{
        "raw" : {
                "mongos2:27018" : {
                        "ok" : 0,
                        "errmsg" : "ns not found"
                }
        },
        "ok" : 0,
        "errmsg" : "{ mongos2:27018: \"ns not found\" }"

j...@avos.com

unread,
Jun 25, 2013, 10:32:44 PM6/25/13
to mongod...@googlegroups.com
I tried this, not work

on mongos:
mongos> db.system.indexes.remove( { "ns" : "meiwei.${mongo.thumbnail}.files" } )
can't delete indexes on sharded collection yet

on mongodb:
> db.system.indexes.remove( { "ns" : "meiwei.${mongo.thumbnail}.files" } )
cannot delete from system namespace
Reply all
Reply to author
Forward
0 new messages