简体   繁体   English

使用MongoDB runCommand方法

[英]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.

相关问题 在java中使用MongoDB的runCommand方法 - Using the MongoDB runCommand method in java 从runCommand升级mongo搜索以使用Java驱动程序进行查找 - Upgrading mongo search from runCommand to find using Java driver Mongo Java驱动程序:如何通过db.runCommand返回的Cusor ID在MongoDB中创建游标 - Mongo Java Driver : How to create cursor in MongoDB by Cusor id returned by a db.runCommand MongoDB 文档更新数组元素使用 Java 中的 findOneAndUpdate 方法 - MongoDB document update array element using findOneAndUpdate method in Java 使用find() - 使用投影方法,使用mongodb java驱动程序3.4检索数据 - retrieving data with mongodb java driver 3.4 using find()-method with projection 找不到MongoDB排序方法 - MongoDB Sort Method Not Found 如何使用 CRUD 方法的 mongodb java 驱动程序修复 java 中的“方法 MongoClient 未定义”错误 - How to fix 'The method MongoClient is undefined' error in java using mongodb java drivers for CRUD method ArrayList类型中的方法add(Filters) <Filters> 不适用于使用Java的mongodb中的参数(Bson)? - The method add(Filters) in the type ArrayList<Filters> is not applicable for the arguments (Bson) in mongodb using java? 在 spring 启动 mongodb 中使用方法查询时如何为所有查询添加默认查询条件 - How to add default query criteria for all the queries when using method queries in spring boot mongodb Spring Data MongoDB - 聚合方法 - Spring Data MongoDB - Aggregate Method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM