What is wrong with this aggregate pipeline method?

I have a database with over 1000 reviews, I am trying to list all of the reviewers who have written at least 5 reviews, I am trying to show the reviewer ID, reviewer name, and number of reviews for each user and then list the names in alphabetical order, I have attempted it several times and just do not understand, my code is below;

db.P_reviews.aggregate([{
$group:{ _id: { “_reviewerID” : “$_reviewerID” },
{ $match: { “_reviewCount”:{$gt:4}}},
{ $project : { “_reviewerID”:1, “_reviewerName”:1, “_reviewerCount”:1}}}}])

I do not understand what is wrong here

First it is $group not group.

Second please concentrate your question in one thread. Please implement correctly what 3 different persons proposed. The $group is far from what was given, it is missing the $sum operation and the way the to have the name in the next stage.

As already mentioned in the 2 other threads, $project and $match are useless as after the $group you are only left with _reviewerID.

3 Likes