बैकग्राउंड में इंडेक्स बनाने के लिए createIndex() मेथड का उपयोग करें और "background: true" सेट करें:
db.yourCollectionName.createIndex({"yourFieldName1":1,"yourFieldName2":1},{background: true});
इंडेक्स बनाने और बैकग्राउंड सेट करने के लिए उपरोक्त सिंटैक्स को लागू करें:
> db.indexCreationDemo.createIndex({"StudentName":1,"StudentAge":1},{background: true});
{ "createdCollectionAutomatically": true, "numIndexesBefore": 1, "numIndexesAfter": 2, "ok": 1 }
इंडेक्सेस डिस्प्ले करें:
> db.indexCreationDemo.getIndexes();
आउटपुट: