Vote count:
0
i need to use mongodb java aggregate function to detect duplicated documents in collection, this is the query i ran from command line and it worked:
db.placements.aggregate({$group:{_id: "$campaign", total:{$sum:1}}}, {$match: {total: {$gt:2}}}, {$limit:10}, {$skip:0});
and this is the java code i wrote:
DBObject groupFields = new BasicDBObject("_id", "$campaign");
groupFields.put("total", new BasicDBObject("$sum", 1));
DBObject group = new BasicDBObject("$group", groupFields);
DBObject matchFields = new BasicDBObject("total", new BasicDBObject("$gt", 2));
DBObject match = new BasicDBObject("$match", matchFields);
collection.aggregate(match, group, new BasicDBObject("$skip", 0), new BasicDBObject("$limit", 10));
but it always return empty result. can anyone tell me what's wrong?
asked 21 secs ago
Aucun commentaire:
Enregistrer un commentaire