3
,比如我有这样的文件集富:MongoDB的索引(ensureIndex)
{"tag_cloud":[{"value":"games", "count":10}, {"value":"girls", "count":500}]}
{"tag_cloud":[{"value":"games", "count":5}, {"value":"stack", "count":100}]}
{"tag_cloud":[{"value":"mongodb", "count":1000}, {"value":"thread", "count":15}]}
两类指标之间有什么区别:
- ensureIndex({ “tag_cloud”})
- ensureIndex({“tag_cloud.value”}); ensureIndex({ “tag_cloud.count”})
在请求上下文:
db.foo.find({"tag_cloud.value":"games"}).sort({"tag_cloud.count":-1});
谢谢!
dcrosta谢谢!!!;) – Edward83 2012-03-29 04:46:13