Group by with limit and sort for each group
db.getCollection('logSrcDest').aggregate(
{
$group: {
_id: {
"src": "$srcId",
"dest": "$destId",
"account": "$account"
},
total: { $sum : "$count" }
}
},
{ $sort: { total : -1 } },
{ $limit: 10 }
);
I have gone through this : mongo with limit and sort but i couldn't find the answer i required.
Any help in this regard will be appreciated