mongoDB+ES

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

2019-03-01  本文已影响1人  布口袋_天晴了

从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('索引名')

上一篇 下一篇

猜你喜欢

热点阅读