Description
Currently, explain.executionStats.nReturned reads: Number of documents that match the query condition. It should instead be the number of documents returned by the winning plan. This subtle difference can be seen in the following scenario:
I have the following docs in my collection:[\{a: 1}, \{a: 2}, \{a: 3}] and run the agg pipeline [{$addFields: {"diff": {$subtract: [5, "$a"]}, {$match: {"diff": {$lte: 2}}}]{}}}, we return 1 doc. When running explain on this aggregate, the winning plan in the case of the classic engine is just COLLSCAN (without any filter) and nReturned is 3.