Remove duplicate documents from collection in mongodb 3.X
From mongodb 2.6 “dropDups” option with creation of unique index is deprecated.
Use the below command to remove the duplicate documents in mongodb.
db..find({}, {“”:1}).sort({_id:1}).forEach
(
function(doc)
{
db..remove({_id:{$gt:doc._id}, <attribute/column name:doc.<attribute/column name});
}
)