Aggregate/project Sub-document As Top-level Document In Mongo
Answer : When you have many, many fields in the sub-document and occasionally it is updated with new fields, then projection is not a viable option. Fortunately, since 3.4, MongoDB has a new operator called $replaceRoot . All you have to do is add a new stage at the end of your pipeline. db.getCollection('sample').aggregate([ { $replaceRoot: {newRoot: "$command"} }, { $project: {score: 0 } //exclude score field } ]) This would give you the desired output. Note that in case of aggregation (especially after a $group stage) the 'command' document could be an array and could contain multiple documents. In this case you need to $unwind the array first to be able to use $replaceRoot . As you have guessed, $project allows you to do that: db.col.aggregate([ { $project : { _id: "$command._id", name: "$command.name", strike: "$command.strike", duratio...