Database
[{"collection":"collection","count":1000000,"content":{"name":{"type":"string","minLength":0,"maxLength":5},"key":{"type":"int","min":"0","max":"100000"}},"indexes":[{"name":"name_1__id_1","key":{"name":1,"_id":1}}]}]
Query
db.collection.aggregate([{$match:{name:{$ne:null}}},{$group:{_id:"$name",count:{$sum:1},docs:{$push:"$_id"}}},{$match:{count:{$gt:1}}}]).explain()