1.为普通字段添加索引,并且为索引命名
db. 集合名 .createIndex( {" 字段名 ": 1 },{" name ":'idx_ 字段名 '})
说明: (1)索引命名规范:idx_<构成索引的字段名>。如果字段名字过长,可采用字段缩写。
(2)字段值后面的 1 代表升序;如是 -1 代表 降序。
2.为内嵌字段添加索引
db. 集合名 .createIndex({" 字段名 . 内嵌字段名 ":1},{"name":'idx_ 字段名 _ 内嵌字段名 '})
3.通过后台创建索引
db. 集合名 .createIndex({" 字段名 ":1},{"name":'idx_ 字段名 ', background:true })
4:组合索引
db. 集合名 .createIndex({" 字段名1 ":-1," 字段名2 ":1},{"name":'idx_ 字段名1 _ 字段名2 ',background:true})
5.设置TTL 索引
db. 集合名 .createIndex( { " 字段名 ": 1 },{ "name":'idx_ 字段名 ', expireAfterSeconds : 定义的时间,background:true} )
说明 :expireAfterSeconds为过期时间(单位秒)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Artificial Intelligence
Stuart Russell、Peter Norvig / Pearson / 2009-12-11 / USD 195.00
The long-anticipated revision of this #1 selling book offers the most comprehensive, state of the art introduction to the theory and practice of artificial intelligence for modern applications. Intell......一起来看看 《Artificial Intelligence》 这本书的介绍吧!
RGB转16进制工具
RGB HEX 互转工具
HEX HSV 转换工具
HEX HSV 互换工具