2

MongoDBrunCommandメソッドの使用方法

db.col.runCommand("text",{search:"searchword"})MongoDB コンソールから全文検索を行うために使用しています。しかし、Javaでこのコマンドを使用したいのですが、Javaでこれを使用する方法を教えてもらえますか?

4

1 に答える 1

4

これを試すことができます:

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);
于 2013-06-28T09:18:24.933 に答える