2

I'm trying creating indexes on a MongoDB collection and while they are correctly created and they work (I can see the index in the executionStats), the output of the getIndexes() function is an empty array:

> db.shopOrder.createIndex({'userId': 1});
{
    "createdCollectionAutomatically" : false,
    "numIndexesBefore" : 2,
    "numIndexesAfter" : 3,
    "ok" : 1
}
> db.shopOrder.getIndexes();
[ ]

I'm using MongoDB 3.6, why does this happen?

  • 1
    Can you edit your question to include the output of version() and db.version() in the mongo shell? – Stennie Sep 26 '18 at 22:00
  • 1
    Thank @Stennie your comment made me realize I was using the old client (ver. 2.6), when I swtiched to the 3.6 one it's all working – Matteo Riva Sep 27 '18 at 8:14

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.