azure - documentDB 中的 COUNT 不起作用

标签 azure azure-cosmosdb

我正在尝试获取我的集合中的文档数量(国家/地区 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/

相关文章:

azure - 在 Azure Function 中将自定义 JsonSerializerSettings 与 DocumentDb 结合使用

php - Azure网站+mysql

ios - Xcode(iOS 应用程序)如何使用私有(private)存储库中托管的 swift 包?

c# - 使用 Cosmos DB 配置 EF Core 以存储字符串的 ICollection

azure - 有没有办法将免费套餐折扣应用于现有的 CosmosDB 资源?

java - 使用 Gremlin 连接到 Azure cosmossDB 模拟器时超时连接

bash - 生成 SAS 以访问 Azure 存储

Azure SQL 数据仓库 Polybase 查询 Azure Data Lake Gen 2 返回零行

azure - 将应用服务证书与 Service Fabric 结合使用

django - 如何将 Django 与 Azure Cosmos DB 结合使用?