Lab Chapter 4 - First match trap

The first match of the official answer is removing imdb rated movies without metacritic field. The result of this pipeline is all movies that have the both notes, imdb and metacritic. But if it was intentional, in my opinion is wrong because there are no specifications about this condition on the question. So, if the condition “no empty” is inside each facet pipeline, we will not get any intersection, because Godfather has 9.2 and the 10º imdb movie (The Real Miyagi) has 9.3

Hey @Doglas_Santana,

Welcome to the MongoDB Community Forums! :four_leaf_clover:

We begin with a $match stage to only look at documents with the relevant fields, in this case, IMDB-rated movies and Metacritic fields.

This was done as the question asks about the movies that are in both the top ten highest rated movies according to the imdb.rating and metacritic fields. Hence, we first used $match to only look at the documents that contain these two fields. A movie that is in the top 10 highest imdb.rating but contains no metacritic field will not be a part of the answer and same for those containing metacritic field and no imdb.rating, hence the first $match stage.

That said, there can always be more than one way to reach the answer and you can definitely try another approach too if you think that your query is doing the same thing. I also know the wording of the question can certainly be improved and will forward this feedback to the team as well.

Let us know if you have still have any confusion regarding this. Feel free to reach out for anything else as well.

Regards,
Satyam

3 Likes

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