Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 MongoDBrunCommand方法?
runCommand
我正在使用db.col.runCommand("text",{search:"searchword"})从 MongoDB 控制台进行全文搜索。但是我想在 Java 中使用这个命令,有人可以建议我如何在 Java 中使用这个命令吗?
db.col.runCommand("text",{search:"searchword"})
你可以试试这个:
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);