不支持聚合阶段:'$bucket'

问题描述 投票:0回答:1

我正在使用 mongodb 并使用带有聚合的存储桶阶段查询数据库。
MongoDB 版本:

db.serverBuildInfo()
{ 
    "version" : "3.6.0", 
    "versionArray" : [
        3.0, 
        6.0, 
        0.0, 
        0.0
    ], 
    "bits" : 64.0, 
    "maxBsonObjectSize" : 16777216.0, 
    "ok" : 1.0
}

我的查询是:

db.data.aggregate(
[    
    {
        "$bucket": 
        {
            groupBy: "$h_id",
            boundaries: [ 0, 100, 200, 300],
            default: "Other",
            output: {
                "count": { $sum: 1 },
            }
        }
    },
]);

我收到错误:

无法执行所选命令

Mongo 服务器错误(MongoCommandException):命令失败并出现错误 304:'不支持聚合阶段:服务器上的'$bucket'' mongodb-测试:27017。

完整回复是:{ “好的”:0.0, "errmsg" : "不支持聚合阶段:'$bucket'", “代码”:NumberInt(304) }

在文档中我可以看到从3.4版本开始,mongodb中就包含了bucket。 https://docs.mongodb.com/v3.6/reference/operator/aggregation/bucket/

任何人都可以指出这个错误的原因是什么......

aggregation-framework bucket aws-documentdb-mongoapi
1个回答
0
投票

在 Amazon DocumentDB 中,不支持 MongoDB 中常用的多个 MongoDB 聚合运算符,例如 $bucket、$facet 等。 Amazon DocumentDB 提供与 MongoDB API 和功能子集的兼容性,但某些功能可能有所不同或不可用。

有关 Amazon DocumentDB 支持的 MongoDB API 的更多信息,您可以参考官方文档这里

© www.soinside.com 2019 - 2024. All rights reserved.