This techniques to find out dupes in a MongoDB collection uses Map Reduce. The steps involved are simple:
Create a script called, say checkdupes.js add the following code to it. The script runs on a collection called myCollection and examines the values of the field called myField, for each distinct value of myField, it inserts a document in a new collection called myDupesCollection.
m = function () { emit(this.myField, 1); } r = function (k, vals) { return Array.sum(vals); } res = db.myCollection.mapReduce(m, r, { out : "myDupesCollection" });
The script above can be run from the command line as follows
mongo myDB checkdupes.js
Now check for the dupes in the newly created collection by running the following command
db.myDupesCollection.find({value: {$gt: 1}});
Pingback: How to remove duplicates based on a key in Mongodb? – oraerr.com
Hello badc0da,
Thanks for Sharing this!!!
We also share that type of problem.
You can view here: https://zappysys.com/blog/ssis-loading-data-into-mongodb-upsert-update-delete-insert/
Hope it will help you…
LikeLike
Hello badc0da
Thanks for Sharing!!!
We also share that type of problems.
You can view here: https://zappysys.com/blog/ssis-loading-data-into-mongodb-upsert-update-delete-insert/
Hope it will help you…
LikeLike
Very useful! Thanks for sharing it.
LikeLike
thanks!
LikeLike
You can share your own knowledge by writing in a
blog, or enrich your knowledge by reading someone else’s. This method
assumes both blog applications are installed
in the same domain and to the same database.
LikeLiked by 1 person