I'm trying to find the user with the most friends from a Yelp dataset on studio3t using mongodb. I am using studio3t's aggregation tool.
First I selected "name
" and "friends
" with $project
Next, I wanted to group by the name of each user, and then sum the number of friends that correspond to that user
{
_id : "$name",
numberoffriends: {$sum : "$friends"}
}
However, I get a result that returns the names but returns a sum value of 0 for each name, which isn't correct.
Should I be using a sum operator? or is there a better operator for this function such as count?