我正在尝试获取我的集合中的文档数量(国家/地区 ID id 分区键)
当我执行没有分区键的普通查询时,如下所示,出现错误
SELECT COUNT(c.memberId) FROM c
Error :- Cross partition query only supports 'VALUE ' for aggregates.
后来我在where条件下添加了分区键
SELECT COUNT(c.memberId) FROM c where c.countryId=209
当我每次执行查询时都会得到不同的结果,例如
[ { "$1": 39161 } ]
[ { "$1": 400454 } ]
[ { "$1": 300454 } ]
[ { "$1": 200454 } ]
为什么它不能正常工作?我的查询有错误吗?
最佳答案
When using the Azure Portal's Query Explorer, note that aggregation queries may return the partially aggregated results over a query page. The SDKs will produce a single cumulative value across all pages.
(来自 docs )
如果您在门户中运行查询,请检查信息 Pane 中的HAS MORE RESULTS
是否为true
。您必须将所有部分结果相加才能得到总数。
关于azure - documentDB 中的 COUNT 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43628999/