In an aggregation pipeline, you have a $match stage placed AFTER a $group stage. The $match filters on a field produced by the $group. Why can this not be pushed before the $group by the optimizer?
db.sales.aggregate([
{ $group: { _id: "$region", total: { $sum: "$amount" } } },
{ $match: { total: { $gt: 1000 } } }
])