MongoDb-查询特定子文档

MongoDb-查询特定子文档,mongodb,sitecore,mongodb-query,sitecore8,Mongodb,Sitecore,Mongodb Query,Sitecore8,我有一套结构如下的mongodb文档: { "_id" : NUUID("58fbb893-dfe9-4f08-a761-5629d889647d"), "Identifiers" : { "IdentificationLevel" : 2, "Identifier" : "extranet\\test@test.com" }, "Personal" : { "FirstName" : "Test",

我有一套结构如下的mongodb文档:

{
    "_id" : NUUID("58fbb893-dfe9-4f08-a761-5629d889647d"),
    "Identifiers" : {
        "IdentificationLevel" : 2,
        "Identifier" : "extranet\\test@test.com"
    },
    "Personal" : {
        "FirstName" : "Test",
        "Surname" : "Test"
    },    
    "Tags" : {
        "Entries" : {
            "ContactLists" : {
                "Values" : {
                    "0" : {
                        "Value" : "{292D8695-4936-4865-A413-800960626E6D}",
                        "DateTime" : ISODate("2015-04-30T09:14:45.549Z")
                    }
                }
            }
        }
    }
}
如何使用mongo shell进行查询,在Tag.Entries.ContactLists.Values路径中查找具有特定“值”(例如{292D8695-4936-4865-A413-800960626E6D})的所有文档


不幸的是,该结构被Sitecore锁定,因此不能使用其他结构。

由于示例集合结构显示
是对象,因此它只包含一个
。此外,您还必须检查
,因为它包含额外的参数。如果您想从给定对象中获取
请尝试以下查询:

db.collection.find({
"Tags.Entries.ContactLists.Values.0.Value": "{292D8695-4936-4865-A413-800960626E6D}"
})

我想我已经试过了,但显然我的查询中出现了一些错误。它很有效!而且你不应该在结构中使用动态键,如
0
。编写查询并不方便。我知道-是Sitecore生成了数据,所以很遗憾,我无法控制结构