Wrong awards data


When I look at values for award field in the database, I have only something like that : “1 win.” or “2 wins.” and never as described in the exercice (Won 13 Oscars…).

Just to validate, I get the values with this query :
db.movies.find({}, {awards : 1})

May be I am using the wrong database ? I am connecting wtih the command line indicated in the chapter 1.

Thanks for your help

Only those who won the Oscars has “Won X Oscars” in the awards field. You should find a way to filter it.

Thank you for your answer, but there is no document with “Won X Oscars” in the database. May be I am connected to the wrong database.

I use this command to connect :

mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/aggregations?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

Hum hum… I tried another query :

db.movies.find({awards: {$exists : true}}, {awards : 1})

and I have all the data (and specially awards with Won in the field).

But I do not understand why they don’t be returned with this query :

db.movies.find({}, {awards : 1})

The second param of db.collection.find() means projection. So db.movies.find({}, {awards: 1}) means that the result will not remove awards field.

And in movie collection, there are 40000+ documents and only half of them has “awards” field, only 2000+ has ‘Oscar’ in its value. And mongodb just return 20 documents in one time. I tried your first query and I had to type at least 20 times "it’ to find a document “Won 3 Oscars”.

@ claude_63078

As @ SauceOil says, there are a lot of documents in this collection, and you don’t seem to be filtering effectively. I would recommend that you create a simple find() operation looking for “awards” that contain the word “Oscar”. A quick check of the collection shows that there are 2680 documents in this collection that satisfy that criteria. Good luck.


Thanks all. You are right, it was a problem of filtering.

This Lab seemed to be easy enough, but again I am struggling - the results are not resembling one of the possible answers.

{ $match : {awards: /Oscar/,  "imdb.rating" : {$gte : 0 }  }  } ,
{ $group : {
		_id : null, 
		"highest_rating" : {$max: "$imdb.rating"} ,
		"lowest_rating" : {$min: "$imdb.rating"} , 
		"average_rating" : {$avg: "$imdb.rating"} ,
		"deviation" : {$stdDevSamp: "$imdb.rating"} , 
		"count" : { $sum : 1}


Again, I am getting results and indeed the count is 2680 - so I am really struggling to understand why the min, max, avg and stdDev are not correct. Can anyone point me in the right direction please?

Got it now - the word “Oscar” in “awards” does necessarily mean they won one!