我的 mongodb 中有一些文件如下
{"Filename":"PHP Book.pdf","Author":"John" ,"Description":"This is my PHP Book"}
{"Filename":"Java Book.html" ,"Author":"Paul" ,"Description":"This is my JAVA Book"}
{"Filename":".NET Book.doc" ,"Author":"James" ,"Description":"This is my .NET Book"}
我在描述字段上创建了文本索引,下面是我在描述字段上进行全文搜索的代码。
m = new Mongo("10.0.0.26", 27017);
DB db = m.getDB("soft") ;
DBCollection col = db.getCollection("pocnew") ;
String collection = col.toString();
DBObject searchCmd = new BasicDBObject();
searchCmd.put("text", collection);
searchCmd.put("search", "php");
CommandResult commandResult = db.command(searchCmd);
System.out.println(commandResult);
我得到以下结果
{ "serverUsed" : "/10.0.0.26:27017" , "queryDebugString" : "php||||||" , "language" : "english" , "results" : [ { "score" : 0.5833333333333334 , "obj" : { "_id" : { "$oid" : "51cd7d302d45471420c1132b","Filename":"PHP Book.pdf","Author":"John" ,"Description":"This is my PHP Book"}]}}
我的要求是仅显示文件名字段值,即仅PHP Book.pdf
请建议我
谢谢