We have a mongoDB database. In a collection there is an existing Text Index, which is not used anywhere now(it was being used, but now that functionality is now removed). And I wanted to update that index with new fields. I didn't find any updateIndex function in MongoDB doc.
So I wrote a script that will first drop that particular index and create a new one in its place because mongoDB allows only one text index at a time.
I want to know that is there any update command?
Is this a good approach or is there any better approach than this?
Thanks!
conn = new Mongo();
db = conn.getDB("test");
db.books.dropIndex({name: "old-index"});
db.books.createIndex({
"notes": "text", "articles.description":
"text", "categories": "text"
},
{name: "new-index"});