Last Updated: February 25, 2016
·
130
· snehaldot

MongoDB: find duplicates in a field

db.mycollection.aggregate([
{$group : { id: "$myfield" , count : { $sum: 1}}},
{$match : { count : { $gt : 1 } }} ])