2017-06-16 61 views
0

当我对DocumentDb发出一个linq计数时。 第一个POST web请求导致400错误请求DocumentDb - 不支持期望从聚合函数获得全部结果的查询

请求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不支持

这分区键范围。

那么对于数查询其作品另一个帖子Web请求:

请求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这种预期的行为。

感谢

多纳尔说希望从聚合函数的全部结果

回答

0

查询不支持

我做一个测试,同样的错误“查询预计从汇总全部结果功能不支持“出现在我身边,如果x-ms-documentdb-query-iscontinuationexpected请求标头设置为false。

enter image description here

x-ms-documentdb-query-iscontinuationexpected请求头为True,并且请求是OK

enter image description here

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

+0

您好弗雷德, 我忘了提及我使用DocumentClient创建查询,而不是我直接进行REST调用。代码大致是: \t var query = documentClient.CreateDocumentQuery (collectionUri); \t \t .Where(doc => doc.field1 ==“MyTypeName”); \t int count = await query.CountAsync(); 我检查了头,x-ms-documentdb-query-iscontinuationexpected对于第一次调用是False。 第二次调用该头没有指定,但指定了x-ms-documentdb-partitionkeyrangeid,我猜测它来自第一次调用之后的调用。 谢谢,Donal –