Couchdb 如何在查询/选择器中使用无名列表中的元素?

Couchdb 如何在查询/选择器中使用无名列表中的元素?,couchdb,cloudant,Couchdb,Cloudant,我不知道如何在Cloudant中查询无名列表中的元素。我似乎找不到任何关于它的文档,我开始怀疑它是否可能 因此,我有一个JSON数据库,其中包含以下文档: { "something": { "object_name:" "test object", "something_else: [ { "value": "test", "desc": "some test valu

我不知道如何在Cloudant中查询无名列表中的元素。我似乎找不到任何关于它的文档,我开始怀疑它是否可能

因此,我有一个JSON数据库,其中包含以下文档:

{
    "something": {
        "object_name:" "test object",
        "something_else: [
            {
                "value": "test",
                "desc": "some test value
            },
            {
                "value": "another test",
                "desc": "some other test value
            }
        ]
    }
}
我尝试构建如下选择器:

{
    "selector": {
        "something": {
            "something_else": [
                {
                    "value:" "test"
                }
            ]
        }
    }
}
但这似乎不起作用


我必须如何构建选择器,以便能够通过“value”内容成功地查询JSON文档?

好的,我刚刚找到了自己的答案。似乎您可以使用“$elemMatch”操作符。在我的示例中,它将如下所示:

{
"selector": {
    "something": {
        "something_else": [
            "$elemMatch": {
                "value:" "test"
            }
        ]
    }
}
}