【发布时间】:2019-11-18 12:10:48
【问题描述】:
我需要从 CosmosDB 查询具有空数据数组(如 [null])的项目。
我试过这样的查询 SELECT TOP 1 c.id from c where ARRAY_CONTAINS(c.data1, [[null]], true)。我的意图是查询这样的内容。
SELECT TOP 1 c.id from c where ARRAY_CONTAINS(c.data1, [[null]], true)
上述查询没有返回任何结果。
var sampledata = `{
"id": 48259,
"data": [
[
{
"Elements": [
{
"QS": "",
"TypeC": "C",
"Id": 378,
"R": false,
"KTime": "0",
"AllKVal": "",
"KVal": "2",
"IsGreen": false
}
]
}
],
[
null,
{
"Elements": [
{
"QS": "",
"TypeC": "CM",
"Id": 243,
"R": "",
"KTime": "0",
"AllKVal": "",
"V": true,
"KVal": "2",
"IsGreen": false
}
]
}
]
],
"_ts": 1560943024
}`;
【问题讨论】:
-
我想我得到了我期望的结果。我删除了额外的方括号并给出了结果。我还在测试。 SELECT TOP 10 c.id, c.documentrecrodid from c where ARRAY_CONTAINS(c.data,[null],true) ORDER BY c.createdon DESC。我只解决了一半的问题,它给出了模式 [null] but [null], .
-
不知道
I has solved only half the problem only, it gives the pattern [null] but [null]是什么意思。你的第二个 sql 是干什么用的?任何进一步的样本数据?您的预期结果是什么? -
嗨,Jay,我已经更新了 sn-p。 {...,[null, { "元素": [......}.这是我试图查询但找不到简单方法的模式。如果您看到该数组有一个空值,而另一个有一个 JSON 对象。希望我说得通。
标签: json azure-cosmosdb azure-cosmosdb-sqlapi