[英]Using the MongoDB runCommand method
How to use MongoDB runCommand
method? 如何使用MongoDB
runCommand
方法?
I am using db.col.runCommand("text",{search:"searchword"})
to do full text search from MongoDB console. 我正在使用
db.col.runCommand("text",{search:"searchword"})
从MongoDB控制台进行全文搜索。 But I want to use this command in Java, can any one suggest me how to use this in Java? 但是我想在Java中使用此命令,有人可以建议我如何在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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.