Hi,
I am copying indexes from one collection to another using :
db.ORIGINAL_TABLE.getIndexes().forEach( function( i ) { db.COPY_TABLE.ensureIndex( i.key );} );
All the indexes are copied over except unqiues and background=true:
example result
Original Table
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "analytics_api..ORIGINAL_TABLE"
},
{
"v" : 1,
"unique" : true,
"key" : {
"accounttoken" : 1,
"date" : -1
},
"name" : "accounttoken_1_date_-1",
"ns" : "analytics_api..ORIGINAL_TABLE",
"background" : true
},
{
"v" : 1,
"key" : {
"embeds" : -1
},
"name" : "embeds_-1",
"ns" : "analytics_api..ORIGINAL_TABLE",
"background" : true
},
{
"v" : 1,
"key" : {
"plays" : -1
},
"name" : "plays_-1",
"ns" : "analytics_api..ORIGINAL_TABLE",
"background" : true
},
{
"v" : 1,
"key" : {
"completes" : -1
},
"name" : "completes_-1",
"ns" : "analytics_api..ORIGINAL_TABLE",
"background" : true
}
]
Copied Table
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "analytics_api.COPY_TABLE"
},
{
"v" : 1,
"key" : {
"accounttoken" : 1,
"date" : -1
},
"name" : "accounttoken_1_date_-1",
"ns" : "analytics_api.COPY_TABLE"
},
{
"v" : 1,
"key" : {
"embeds" : -1
},
"name" : "embeds_-1",
"ns" : "analytics_api.COPY_TABLE"
},
{
"v" : 1,
"key" : {
"plays" : -1
},
"name" : "plays_-1",
"ns" : "analytics_api.COPY_TABLE"
},
{
"v" : 1,
"key" : {
"completes" : -1
},
"name" : "completes_-1",
"ns" : "analytics_api.COPY_TABLE"
}
]
What am I missing?