创建索引
db.comment.createIndex({userid:1})
comment是数据库的名称, userid是数据库的字段
查看索引
db.comment.getIndexes()
创建复合索引
db.comment.createIndex({userid:1,nickname:-1})
字段名包括userid 和nickname
移除索引
db.comment.dropIndex({userid:1})
移除复杂的索引
db.comment.dropIndex("userid_1_nickname_-1")
移除所有的所有
db.comment.dropIndexes()