3
我試過在網上搜索這個錯誤,但沒有任何幫助。我正嘗試在使用Java的mongodb中使用aggregate
函數。 RetailerZip
是我想將我的結果分組的字段。安裝
groupFields = new BasicDBObject("_id", 0);
groupFields.put("count",new BasicDBObject("$sum",1));
groupFields.put("_id", "$RetailerZip");
group = new BasicDBObject("$group", groupFields);
sort = new BasicDBObject();
projectFields = new BasicDBObject("_id", 0);
projectFields.put("value", "$_id");
projectFields.put("ReviewValue","$count");
project = new BasicDBObject("$project", projectFields);
sort.put("ReviewValue",-1);
orderby=new BasicDBObject("$sort",sort);
limit=new BasicDBObject("$limit",5);
List<DBObject> pipeline = Arrays.asList(group, project, orderby, limit); //error occurs on this line.
AggregationOutput output = mongo.myReviews.aggregate(pipeline);
MongoDB的版本是:3.2.11
您可以加入你所得到的錯誤的詳細信息?還有什麼'組','項目'等是對象? – nullpointer
什麼是'RetailerZip'沒有在問題中提到。問題肯定需要改進。 – nullpointer