2017-06-16 59 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 –