How to use MongoDB runCommand method?
I am using db.col.runCommand("text",{search:"searchword"}) to do full text search from MongoDB console. But I want to use this command in Java, can any one suggest me how to use this in Java?
You can try this:
DBObject searchCmd = new BasicDBObject();
searchCmd.put("text", collection); // the name of the collection (string)
searchCmd.put("search", query); // the term to search for (string)
CommandResult commandResult = db.command(searchCmd);