Lab - Bringing it altogether

My aggregation pipeline is not producing the right results.

db.movies.aggregate([REMOVED]).pretty()

Any suggestions?

First, you do not have to put your ‘$match’ in different stage. You may have

{’$match’:{‘languages’:{…},‘imdb.rating’:{…},…,‘year’:{…}}}

What is the error?

It runs without error, but the result doc is not among the multiple choices. It is not finding the right doc.

I tried to run the pipeline and got:

SyntaxError: missing : after property id

When I look at what I got from cut-n-paste and what I see in your posting is different. In my cut-n-paste I don’t have quotes around the $imdb.rating of the last $addFields. Try using single quotes.

It does actually run without errors, I guess the " conversion is due to some intermediate editor (I’ve already passed the lab but I misunderstood the problem so primarily by luck. I can confirm Harriett’s code looks - to my current understanding - as required, runs after find/replacing the unicode " characters with the standard one, I even checked the normalized rating for the first few hits and they seemed correct to me too).

It returns

{
“title” : “Halo: Nightfall”,
“year” : “2014�”,
“languages” : [
“English”
],
“imdb” : {
“rating” : 5.7,
“votes” : 2640
},
“scaled_votes” : 1.0155906909473407,
“normalized_rating” : 3.3577953454736704
}

Which does not match any answer in the list.

Ok. I got it. I had misunderstood the question. It was asking which movie in the list was the one with the lowest rating score. Thanks everyone for your help. Your ideas helped me to diagnose what’s going on.