Chapter 1: Basic Aggregation - $match and $project (not able to get correct answer)

not able to get an answer could anyone help me out with the problem I’m getting!!!

here is the aggregation pipeline I’m using:-

[{$match: {
“imdb.rating”: {"$gte": 7},
“genres”: {"$nin": [“Horror”, “crime”]},
“rated”: {"$in": [“PG”, “G”]},
“languages”: {"$in": [“English”, “Japanese”]}
}}, {}]
getting 800 documents :frowning:

Hi @rishabh_prakash :wave: ,

Please note that the Genre name is Crime and not crime.
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

db.movies.aggregate([{$match: { “imdb.rating”: {"$gte": 7}, “genres”: {"$nin": [“Horror”, “Crime”]}, “rated”: {"$in": [“PG”, “G”]}, “languages”: {"$in": [“English”, “Japanese”]} }}]).itcount()

db- aggregations and collections is movies
getting 877 results

Hi @rishabh_prakash,
Also, please note that the question asks you to find movies:

  • languages contains “English” and “Japanese”
    But your pipeline seems to return all the movies that have either “English” OR “Japanese” OR both as languages.

Please learn more about how to get the exact array behavior through our awesome documentation on Array Query Operator.
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

2 Likes

thanks sourabh got it… :slight_smile:

Hi @rishabh_prakash, I am really glad that your issue is resolved now.
Can you please create a new topic for this question along with the additional details and proper context?
This will make it easier to resolve your issue as well as help future learners in referencing it at a later point in time.

Let us know if you have any doubts.

Thanks & Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

its also done sourabh thanks anyway…

1 Like