I managed to do that with this query :-
Suppose you have collection name data1 and you want to make new collection data2 with same indexes or want to delete or add some index you can do this by using this query.
data1 have indexes
| FirstName | MiddleName | LastName | Age | Occupation
and you want to make new collection data2
| FirstName | MiddleName | LastName | Age | Occupation | Date
Query It took very less time in my case (speed depend on amount of data)
var cursor = db.data1.find();
var data = [];
while(cursor.hasNest()){
var a = cursor.next();
data.push({
"FirstName" : a.FirstName,
"MiddleName" : a.MiddleName,
"LastName" : a.LastName,
"Age" : a.Age,
"Occupation" : a.Occupation,
"Date" : new Date()
});
}
db.data2.insertMany(data)
----- UPDATE -----
As this will build in memory array so for large set of data memory consumption will be high, so to solve this problem what one can do is define a flag and after some record let say 1000 you can insert the current data in collection and empty that array.