createIndexes Builds one or more indexes on a collection. Tip In mongosh, this command can also be run through the db.collection.createIndex() and db.collection.createIndexes() helper methods. Helper methods are convenient for mongosh users, but they may not return the same level of informat...
isUnique:false,isSparse:false,isPartial:false,indexVersion:2,direction:'forward',indexBounds:{Title:['["The Lake House", "The Lake House"]']},keysExamined:1,seeks:1,dupsTested:0,dupsDropped:0}}},command:{find:'movies',filter:{Title:'The Lake House'},'$db':'book'},server...
db.adminCommand({currentOp: true,$or:[{op:"command","command.createIndexes":{$exists:true}},{op:"none","msg":/^Index Build/}]}) 返回如下图所示,msg字段指明当前创建索引的进度,locks字段代表该操作的锁类型。更多锁说明信息,请参见MongoDB 官网。
"id":20438,"ctx":"conn15536","msg":"Index build: registering","attr":{"buildUUID":{"uuid":{"$uuid":"c3fa6f65-337e-424e-95f0-a8081b60b5cc"}},"namespace":"miku.demo","collectionUUID":{"uuid":{"$uuid":"cc364994-d259-464e-bf7e-a02d4746f910"}},"indexes":1,"firstIndex"...
("11637555631"),"op":"command","ns":"fs.$cmd","query":{"createIndexes":"trace_info","indexes":[{"key":{"url":"hashed"},"name":"url_hashed","background":true}]},"msg":"Index Build (background) Index Build (background): 406813780/630393144 64%","progress":{"done":406813780...
> db.inventory.createIndex({item:1,unique:true}) 1. //使用下面的命令查看索引完成进度 > db.currentOp( { $or: [ { op: "command", "query.createIndexes": { $exists: true } }, { op: "insert", ns: /\.system\.indexes\b/ } ...
{ "timestamp": "Thu Apr 2 07:51:50.985" , "severityLevel": "I" "components": "COMMAND" "namespace": "animal.MongoUser_58" "operation": "find" "command": { find: "MongoUser_58", filter: { $and: [ { lld: { $gte: 18351 } }, { fc: { $lt: 120 } }, { _id: { $ni...
{ op: "command", "command.createIndexes": { $exists: true } }, { op: "none", "msg" : /^Index Build/ } ] } ) 这个输出的结果是在 Primary 节点上的进度,未体现 Secondary 节点上构建索引的进度,可以理解为“即使这里进度显示100%,也只是代表 Primary 节点已完成索引构建,并不能代表整个副本集...
createIndex() 方法来创建索引 MongoDB使用 createIndex() 方法来创建索引。 注意在 3.0.0 版本前创建索引方法为 db.collection.ensureIndex(),之后的版本使用了 db.collection.createIndex() 方法,ensureIndex() 还能用,但只是 createIndex() 的别名。
db.collection.createIndex(keys, options, commitQuorum) Important mongo Shell Method This page documents a mongo method. This is not the documentation for database commands or language-specific drivers, such as Node.js. To use the database command, see the createIndexes command. For MongoDB API...