mongoDB索引

单一索引:db.users.enureIndex({"username":1})
展示索引:db.collectionName.getIndexes();
复合索引:db.users.enureIndex({"age":1,"username":1})
索引嵌套文档:db.users.ensureIndex({"loc.city":1})
explain()  和 hint()   
唯一索引  db.user.ensureIndex({"username":1},{"unique":true});
稀疏引索:sparse
 
system,indexes集合中,ensureIndex插入。dropIndexes删除
 
 
固定集合:新插入会循环删除
创建> db.createCollection("my_collection",{"capped":true,"size":10000});
size 是大小 可以加上max :10 保持最新的10条   
 
自然排序:{"$natural":1}或-1   就是在磁盘上 的排列顺序
 
循环游标    结果集的游标被取光还会继续去,有新的插入还会取出来。
 
 
ttl索引  有过期时间的索引   db.foo.ensureIndex({"ld":1},{"expireAfterSecs":60})
 
全文索引:db.hn.ensureIndex({"title":"text"})
地理空间索引:
gridFs大型数据“:
原文地址:https://www.cnblogs.com/chenjinxinlove/p/5520922.html