Skip to content

Instantly share code, notes, and snippets.

@jonezy
Created July 9, 2015 21:08
Show Gist options
  • Save jonezy/1cc8caa70b1ad80f1887 to your computer and use it in GitHub Desktop.
Save jonezy/1cc8caa70b1ad80f1887 to your computer and use it in GitHub Desktop.
map reduce mongo
db.XIgniteCompanies.aggregate(
{ $group: {
// Group by fields to match on (a,b)
_id: { a: "$Symbol", b:"$Exchange"},
// Count number of matching docs for the group
count: { $sum: 1 },
// Save the _id for matching docs
docs: { $push: "$_id" }
}},
// Limit results to duplicates (more than 1 match)
{ $match: {
count: { $gt : 1 }
}}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment