【发布时间】:2016-04-26 20:50:46
【问题描述】:
我正在尝试在 Mongo DB 3.2 Java 驱动程序中进行全文搜索
以下是我的代码:
DBObject textSearchCommand = new BasicDBObject();
textSearchCommand.put("text", collectionName);
textSearchCommand.put("search", "MAURICE");
CommandResult commandResult = db.command(textSearchCommand);
System.out.println("Command result is "+commandResult.toString());
出现以下错误:
命令结果是 { "ok" : 0.0 , "errmsg" : "no such command: 'text', bad cmd: '{ text: \"citizen5\", search: \"MAURICE\" }'" , “代码”:59}
我已经创建了 textIndex :
{ "v" : 1 , "key" : { "_fts" : "text" , "_ftsx" : 1} , "name" : "MyTextIndex" , "ns" : "matcher.citizen5" , "weights " : { "address" : 1 , "firstname" : 1 , "lastname" : 1 , "metaaddress" : 1 , "metafirstname" : 1 , "metalastname" : 1 , "mobile" : 1} , "default_language" : "english" , "language_override" : "language" , "textIndexVersion" : 3}
谁能指出我哪里做错了?
【问题讨论】:
标签: mongodb