I am unable to restore indexes with mongorestore command while restoring the collection i am getting the collection but i am unable to restore the indexes with it so whats the solution to restore the indexes with collection

This is the command i am using to restore

mongorestore -h ip:portnumber -u name -p passwd -d databasename -c collectionname --authenticationDatabase admin /d/collection.Bson

my Mongodb version is 3.6

  • is there a collection.metadata.json at the same path location? This is actually required in order to create the indexes, so if it is missing then no indexes will be created. – Neil Lunn Jun 2 '18 at 5:38
  • yes there are two files in backup with.bson and .json i used to restore with bson whats the procedure to get indexes using json – bvk Jun 2 '18 at 5:40
  • There's no procedure just as long as it's actually there and is correctly named. Show what the files are in the directory and look at the content of the related metadata.json file that is there. The content is basically the same as what you see from the getIndexes() command in the shell, or indeed you can simply create the file with the same content. Show the detail by editing your question – Neil Lunn Jun 2 '18 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.