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);