Home > database >  Small white problem, a great god can help look at this kind of writing Java version of execution of
Small white problem, a great god can help look at this kind of writing Java version of execution of

Time:09-26

Project in directing a distributed and someone said that the program useful to group, I need to change the code, does not support cluster environment, the following code
DBObject _match=new BasicDBObject ();
_match. Put (" MAIN_TAG ", "0");
_aggregate. Add (new BasicDBObject (" $match, "_match));
DBObject _group=new BasicDBObject ();
DBObject _id=new BasicDBObject ();
_id. Put (" SUPER_ID ", "$SUPER_ID");
_group. Put (" _id ", _id);
_group. Put (" COUNT ", new BasicDBObject (" $sum ", 1));
_aggregate. Add (new BasicDBObject (" $group ", _group));
AggregationOutput output=mongodbTemplate. GetDB (" XXX "). The getCollection (" XXXXX "). The aggregate (_aggregate);
  • Related