Mongodb version I am using is 3.2.11. and mongo-java-driver jar file version is 3.0.4
Hi Mittal,
I’m not entirely sure why you would be getting the error message. Although I can see a couple of improvements that could be made:
BasicDBObject for MongoDB Java Driver v3.0+ _id entry in your $group that could be removed. See below example:
Document groupFields = new Document("_id", "$RetailerZip").append("count", new Document("$sum", 1));
Document group = new Document("$group", groupFields);
Document projectFields = new Document("value", "$_id").append("ReviewValue", "$count");
Document project = new Document("$project", projectFields);
Document orderby= new Document("$sort", new Document("ReviewValue", -1));
Document limit= new Document("$limit",5);
List<Document> pipeline = asList(group, project, orderby, limit);
AggregateIterable<Document> output = db.getCollection("myReviews").aggregate(pipeline);
If you are still seeing the same error message, could you please provide:
myReviews collection. groupField, groupRegards,
Wan.