Database

[{"collection":"collection","count":5,"content":{},"indexes":[{"name":"idx","key":{"matchField":1,"batchId":1}}]}]

Query

db.collection.aggregate([{"$match":{"matchField":"ABC"}},{"$group":{_id:"$batchId","myMetadata1":{"$first":"$myMetadata1"}}}]).explain()

Result