I want to create a text index on all of my fields in MongoDB. I know that it can be done like this:
db.collection.ensureIndex({ "$**": "text" },{ name: "TextIndex" })
But I want create this index in my Java program. I tried with this:
collection.createIndex(new BasicDBObject("$**","text"),newBasicDBObject("name","TextIndex"));
but it gave me this error:
com.mongodb.MongoException: Can't canonicalize query: BadValue unknown operator: $**
I don't know what to do. I can see that others have asked the similar question but no one answered. Can any of you guys help me?
Thanks in advance.