Are you expecting the documents in the new collections to have the same _id values as the existing documents? If not, you could let mongo create new _id values and store the old (sometimes not unique) _ids values in another property that is not uniquely indexed.
Sorry for my writing a question with low information. Assume we have users collection with these fields: _id, name, address, phoneNumber, age. Now I wanna copy part of my users’ info - Just name and phoneNumber - into another collection named test. In the users collection the phoneNumber field is not indexed (unique).
In the test collection I decided to index my phoneNumber. But now I want to ignore the E11000 duplicate key error on the phoneNumber field and skip those docs with duplicated phoneNumber.
BTW now I figured I have to distinct the users based on their phoneNumber first, then copy them into another collection.
What do you think? Is it good or there are other solutions too?