Last active
August 29, 2015 14:16
-
-
Save zubairalam/a8a364d8c27bd732d05c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Desired unique index: | |
// db.categories.ensureIndex({ category_url: 1, category_page_url: 1 }, { unique: true}) | |
db.categories.aggregate([ | |
{ $group: { | |
_id: { category_url: "$category_url", category_page_url: "$category_page_url" }, | |
uniqueIds: { $addToSet: "$_id" }, | |
count: { $sum: 1 } | |
}}, | |
{ $match: { | |
count: { $gt: 1 } | |
}} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment