【问题标题】:DocumentDb - Query that expects full results from aggregate functions is not supportedDocumentDb - 不支持期望来自聚合函数的完整结果的查询
【发布时间】:2017-06-16 13:34:34
【问题描述】:

当我针对 DocumentDb 发出 linq 计数时。 第一个 POST Web 请求导致 400 Bad request

请求json:

{"query":"SELECT VALUE Count(1) FROM root 
    WHERE ((((root[\"docType\"] = \"Whatever\") 
    AND (root[\"field1\"] = false)) 
    AND (root[\"field2\"] = true)) 
    AND (root[\"field3\"] = 1)) "}

消息: 不支持期望来自聚合函数的完整结果的查询

这后面是 GET 分区键范围。

然后是另一个有效的计数查询的 POST 网络请求:

请求json:

{"query":"SELECT VALUE [{\"item\": Count(1)}]\r\nFROM root\r\n
    WHERE ((((root[\"docType\"] = \"Whatever\") 
    AND (root[\"field1\"] = false)) 
    AND (root[\"field2\"] = true)) 
    AND (root[\"field3\"] = 1))"}

我在这里做错了什么/愚蠢还是 documentDb 的预期行为。

谢谢

唐纳

【问题讨论】:

    标签: azure-cosmosdb


    【解决方案1】:

    不支持期望来自聚合函数的完整结果的查询

    我做了一个测试,如果 x-ms-documentdb-query-iscontinuationexpected 请求标头设置为假的。

    x-ms-documentdb-query-iscontinuationexpected请求头设置为True,请求ok

    请捕获您的请求并检查x-ms-documentdb-query-iscontinuationexpected请求标头的实际值。

    【讨论】:

    • 您好 Fred,我忘了提及我正在使用 DocumentClient 来创建查询,而不是我直接进行 REST 调用。代码大致是: var query = documentClient.CreateDocumentQuery( collectionUri ); .Where( doc => doc.field1 == "MyTypeName" ); int count = await query.CountAsync() ;我检查了标题,第一次调用时 x-ms-documentdb-query-iscontinuationexpected 为 False。在第二次调用中,未指定标头,但指定了 x-ms-documentdb-partitionkeyrangeid,我猜它来自第一个调用之后的调用。谢谢,多纳尔
    猜你喜欢
    • 2020-03-09
    • 2018-03-08
    • 2021-08-28
    • 2020-02-29
    • 2023-02-17
    • 2019-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多