সূচী পুনর্নির্মাণ করতে, reIndex() ব্যবহার করুন। প্রথমে একটি সূচক তৈরি করা যাক। নিচের প্রশ্নটি −
> db.demo42.createIndex({"StudentFirstName":1}); এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{
"createdCollectionAutomatically" : true,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
} MongoDB −
-এ সূচক পুনর্নির্মাণের জন্য নিম্নোক্ত ক্যোয়ারী> db.demo42.reIndex({"StudentFirstName":1}); এটি নিম্নলিখিত আউটপুট −
তৈরি করবে{
"nIndexesWas" : 2,
"nIndexes" : 2,
"indexes" : [
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "web.demo42"
},
{
"v" : 2,
"key" : {
"StudentFirstName" : 1
},
"name" : "StudentFirstName_1",
"ns" : "web.demo42"
}
],
"ok" : 1
}