重建 MongoDB 中的索引?
要重建索引,請使用 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
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP