Can't seem to drop a full text index 2.4.RC0

318 views
Skip to first unread message

kellypw

unread,
Feb 15, 2013, 5:35:58 PM2/15/13
to mongod...@googlegroups.com
Exploring the new full text index and search features - running Windows 7, mongodb version 2.4 RC0.  I created a text index with multiple fields (I forgot to name it), with this:

db.mycol.ensureIndex({"name": "text", "dc.subject" : "text", "dc.description" : "text"})

I'd like to drop it, but I can't seem to drop the index. The index definition looks like this:

{
"v" : 1,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"ns" : "mydb.mycol",
"name" : "name_text_dc.subject_text_dc.description_text",
"weights" : {
"dc.description" : 1,
"dc.subject" : 1,
"name" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 1
}

I've tried the following to no avail:

> db.mycol.dropIndex({"name_text_dc.subject_text_dc.description_text" : 1});
{
"ok" : 0,
"errmsg" : "can't find index with key:{ name_text_dc.subject_text_dc.description_text: 1.0 }"
}

And this:

> db.mycol.dropIndex({"_ftsx" : 1});
{ "ok" : 0, "errmsg" : "can't find index with key:{ _ftsx: 1.0 }" }
> db.mycol.dropIndex({"_fts" : 1});
{ "ok" : 0, "errmsg" : "can't find index with key:{ _fts: 1.0 }" }
>

Any thoughts?  Thanks!


kellypw

unread,
Feb 15, 2013, 5:40:45 PM2/15/13
to mongod...@googlegroups.com
I did a work-around by dropping all indexes on the collection, but would like to know what I'm doing wrong in trying to drop the text index - thanks

Eric Milkie

unread,
Feb 15, 2013, 11:24:52 PM2/15/13
to mongod...@googlegroups.com
The dropIndex command takes two forms; either you can pass a string name of the index, or pass a document that specifies the keys to uniquely identify the index to be dropped.  I think you are conflating these two forms.

Here is what will work if you want to use the form of the dropIndexes command that takes an index name:
> db.mycol.dropIndex("name_text_dc.subject_text_dc.description_text")
{ "nIndexesWas" : 2, "ok" : 1 }

Otherwise, it thinks you are passing the keys of the index.  To use that form instead, you could say:
> db.mycol.dropIndex({"name": "text", "dc.subject" : "text", "dc.description" : "text"})

-Eric

kellypw

unread,
Feb 18, 2013, 12:12:41 PM2/18/13
to mongod...@googlegroups.com
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?

Jeff Lee

unread,
Feb 18, 2013, 1:15:18 PM2/18/13
to mongod...@googlegroups.com
You just need to pass the index name in as a string ( not a doc ).

e.g.

> db.foodle.save({username:'jeff'})
> db.foodle.ensureIndex({username:1},{name:'username_index'})
> db.foodle.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "test.foodle",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"username" : 1
},
"ns" : "test.foodle",
"name" : "username_index"
}
]
> db.foodle.dropIndex('username_index')
{ "nIndexesWas" : 2, "ok" : 1 }


--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

kellypw

unread,
Feb 18, 2013, 1:25:02 PM2/18/13
to mongod...@googlegroups.com
bah - thanks - sorry for the confusion -
Reply all
Reply to author
Forward
0 new messages