Differences between match and project

I have a question in regards to the match and project differences. On the spoiled text down there ( it s a solution to a lab)

First i match the rating then the genres then the languages and then i do the projection but here is the thing:

When i do the projection i specify a query syntax to project only the files with the matching conditions.

var pipeline = [{ $match: {“imdb.rating”: {$gte: 7}, genres: {$nin: [“Crime”, “Horror”]}, languages: {$all: [“English”, “Japanese”]}, rated: {$in: [“PG”, “G”]}}}, { $project: {_id:0, title:{$eq: [1, {$size: {$split : ["$title", " "]}}]}}}]

Does this mean i can put everything in project instead of match?
What are the benefits of using match instead of just overloading the project. Or better said what are the differences?


No, you $project fields, not documents. Check out the documentation on $match here and $project here. If you try to use $project in place of $match, you’ll likely get results you don’t intend – not to mention that you’re still passing the entire collection.