Chapter 3 Lab I - $group and Accumulators - Receiving Null for Result

Hello Team,

I am working on the first lab in Chapter 3 and receiving null for all the calculations. I think there is something wrong with either my $match or $group statements in my aggregation, but I do not see it. Can someone please point out what I am missing and not seeing?

Here is what I have as my code:

    db.getCollection("movies").aggregate([
{
    $match: {
        "awards": /Won \d{1,2} Oscars?/
    }
},
{
    $group: {
        _id: null,
        count: {$sum: 1}
    }
},
{
    $project: {
        "_id": 0,
        "awards": 1,
        "highest_rating": {$max: "$imdb.rating"},
        "lowest_rating": {$min: "$imdb.rating"},
        "average_rating": {$avg: "$imdb.rating"},
        "deviation": {$stdDevSamp: "$imdb.rating"}
    }
}
])

Here is my result:

{ 
    "highest_rating" : null, 
    "lowest_rating" : null, 
    "average_rating" : null, 
    "deviation" : null
}

The $group completely alter the documents and only the fields computed in the stage are sent to the next. The documents are grouped based on the _id specified. In this case all documents are grouped into a single document, because _id:null.

This means, that none of the fields specified in your $project exists anymore.

But you really are not too far. The $max, $min, $avg and $stdDevSamp should all be calculated in the $group.