Created
July 9, 2015 21:08
-
-
Save jonezy/1cc8caa70b1ad80f1887 to your computer and use it in GitHub Desktop.
map reduce mongo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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