Skip to content

Instantly share code, notes, and snippets.

@linkesch
Created October 15, 2013 12:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linkesch/6990564 to your computer and use it in GitHub Desktop.
Save linkesch/6990564 to your computer and use it in GitHub Desktop.
MongoDB - find duplicates
db.items.aggregate(
{ $group : {_id : "$fieldName", total : { $sum : 1 } } },
$match : { total : { $gte : 2 } } },
$sort : {total : -1} },
$limit : 5 }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment