MongoDB Javaドライバーのソースコードがある場合は、com.mongodb.GroupCommand
このクエリがどのように構築されているかを確認できます。次のようになります。
BasicDBObject args = new BasicDBObject();
args.put( "ns" , input );
args.put( "key" , keys );
args.put( "cond" , condition );
args.put( "$reduce" , reduce );
args.put( "initial" , initial );
if ( finalize != null )
args.put( "finalize" , finalize );
return new BasicDBObject( "group" , args );
これが変換するのは、次のようなグループコマンド(http://docs.mongodb.org/manual/reference/command/group/ )です。
{ "group" : { "ns" : "coll" ,
"key" : {<keys>} ,
"cond" : {<cond>} ,
"$reduce" : "<reduce>" ,
"initial" : { }
}
}