Lab: Using Cursor like stages

While using the query:
db.movies.aggregate([{$match: {"countries": "USA", "tomatoes.viewer.rating": {$gte: 3}}}, ....., {$project: {_id: 0, title: 1}}, {$sort: {"num_favs": -1, "tomatoes.viewer.rating": -1, "title": -1}}]).pretty()

I get the answer as shown in the screenshot above.
Considering that, at a time the cursor contains and shows 20 records on the screen the 25’th movie should be as highlighted in the above shot. However if I put the $skip stage that removes the first 24 records, then I get the correct answer, which is different from the one highlighted.

These two should be the same, right? Or am I missing something here?


In both cases, you should get the same answer. But you have to apply the $skip as the last stage.

Your pipeline is wrong. In $project stage you are retaining only the title field. then in the $sort stage how can you sort using num_favs and tomatoes.viewer.rating, when the documents do not contain those fields.