Bringing it all together $match


I have a problem with the solution to this lab work:

I start by adding new fields via $addFields

  • scaled_votes: I calculate with the formula given in scaling.js
  • normalized_rating: I calculate via $avg also by the example from scaling.js

this seems to work fine to me

after that I use filter $match and for some reason I think that the problem is in this part

  • filter a year with $lte
  • votes and rating through $gte: 1
  • languages through $all
  • and type through $eq

afterwards I sort

normalized_rating: 1

to output from less to more

But in the response I get:

    title: 'Malta G.C.',
    year: 1942,
    languages: [ 'English ],
    imdb: { rating: 8.6, votes: 5 },
    scaled_votes: 1,
    normalized_rating: 5

which doesn’t match the answers at all

Where did I do something wrong

Best regards,

Hi @111728, welcome to the community.

Can you explain why? Please note that the lab says:

it was released in 1990 or after.

Therefore it should be $gte.

I hope it helps.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer