Chapter 2 wrong answer

For whatever reason I cannot find how this query gives the wrong answer to the first lab. Any fresh eyes that can help me spot the issue would be appreciated.

var favorites = [
  "Sandra Bullock",
  "Tom Hanks",
  "Julia Roberts",
  "Kevin Spacey",
  "George Clooney"]
  $match :{"tomatoes.viewer.rating":{$gte:3}, countries: "USA", cast: { $in: favorites}}
  $project: {
  _id: 0,
  title : 1,
    {$size :
      {$setIntersection :
{$sort: {num_favs: -1, "tomatoes.viewers.rating": -1, title: -1}},
{$skip : 24},
{$limit : 1},
{$project: {title:1}}

For the next time you publish code or data, see Formatting code and log snippets in posts.

What answer to you get?

Hi Steeve,
“The Ref” is the title I get.

The sort stage has an issue. The field tomatoes.viewers.rating contains a typo.

To find it, I removed the skip, limit and last project stage and looked at the output. I then saw that the order was wrong and then that the field name was wrong.

1 Like

got it, thanks for the help.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.