【发布时间】:2019-03-25 20:00:01
【问题描述】:
当我尝试选择对象数组时,无法进行查询(CosmosDB SQL API)。 我想知道我搜索的所有参数是否都在不同的对象中。
应该找到下一个文档:
{
"_id" : "97e9272d-cd7e-4a26-3245-o4e67h29beqw",
"_type" : "Document",
"categories" : [
{
"_name" : "PruebaCategoria", (searching by this)
"Type" : "omega",
"Policy number" : "1234567890",
"date" : 1553081146391,
"boolean" : true
},
{
"_name" : "CategoryDemoTest",
"Type" : "free",
"Policy number" : "0987654321"
},
{
"_name" : "CategoryDemoTestDates",
"dateInitial" : 1553081146592, (and by this in range)
"dateEnd" : 1553081146594,
"Type" : "omega"
}
],
"partitionNumber" : 1,
"serial" : 1
}
我想复制下一个与 mongodb API 一起使用的查询:
{ "categories" : { "$all" : [{ "$elemMatch" : { "dateInitial" : { "$gt" : { "$numberLong" : "1553081146591" }, "$lt" : { "$numberLong" : "1553081146593" } } } }, { "$elemMatch" : { "_name" : "PruebaCategoria" } }] } }
我尝试了以下查询,但似乎只有一个对象具有我要查找的所有元素时它们才匹配:
"SELECT VALUE c FROM c JOIN cat in c.categories WHERE cat._name=\"PruebaCategoria\" AND cat.dateInitial > 1553081146591 AND cat.dateInitial < 1553081146593"
是否存在进行此类搜索的方法(使用 CosmosDB SQL API)?
【问题讨论】:
标签: azure-cosmosdb azure-cosmosdb-sqlapi