mongodb建立索引&查看索引&删除索引

从Robo 3T可视化界面中,去创建mongodb数据表的索引。

1.数据表结构:{_id:value,   doc_city:value,    doc_province:value,   content,   judgementId}

2.content字段展开:

3.对content字段里的title/caseType/judgementType建立索引

db.getCollection('chongqing').createIndex({"content.title":1, "content.judgementType":1, "content.caseType":1})

4.让创建索引的过程在后台运行

db.getCollection('chongqing').createIndex({"content.title":1, "content.judgementType":1, "content.caseType":1},{background:true})

5.查询集合索引

db.getCollection('chongqing').getIndexes()

6.查看索引集合大小

db.getCollection('chongqing').totalIndexSize()

7.删除集合所有索引

db.getCollection('chongqing').dropIndexes()

8.删除集合指定索引

db.getCollection('chongqing').dropIndex('索引名')

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容