一、Single Field Indexes
示例文档:
{
"_id": Id("570c04a4ad233577f97dc459"),
"score": 1034,
"location": { state: "NY", city: "New York" }
}
1、语法:
db.records.createIndex( { score: 1 } )
2、在嵌套字段上创建索引
db.records.createIndex( { "location.state": 1 } )
查询语法:
db.records.find( { "location.state": "CA" } )
db.records.find( { "location.city": "Albany", "location.state": "NY"
继续阅读与本文标签相同的文章
-
Huffman Tree (哈夫曼树学习)
2026-05-23栏目: 教程
-
利用函数计算流式 gz 打包 ECS 上的单个 超大文件
2026-05-23栏目: 教程
-
函数计算对文件进行压缩和解压缩使用总结
2026-05-23栏目: 教程
-
Python爬虫入门教程 62-100 30岁了,想找点文献提高自己,还被反爬了,Python搞起,反爬第2篇
2026-05-23栏目: 教程
-
云主机远程协同运维利器,好用的远程协同会诊平台推荐
2026-05-23栏目: 教程
