【问题标题】:MongoDB Java driver : no such cmd: aggregateMongoDB Java驱动程序:没有这样的cmd:聚合
【发布时间】:2012-11-21 15:54:08
【问题描述】:

我在我的代码中调用 MongoDB 聚合函数为:

AggregationOutput output = collection.aggregate( matchUserID, unwindF, matchFUsers,projection);

我已经在我的本地主机中测试了我的代码,它运行良好。当我在另一个数据库(2.2.1 版)中使用相同的数据库时,会出现此错误:

com.mongodb.CommandResult$CommandFailure: command failed [aggregate]: { "serverUsed" : "<server address>" , "errmsg" : "no such cmd: aggregate" , "bad cmd" : { "aggregate" : .... }

有什么线索吗?

【问题讨论】:

    标签: mongodb mongodb-query mongodb-java


    【解决方案1】:

    根据我看到的类似问题的其他答案,服务器似乎很可能不是您认为的实际 2.2.1。

    你如何检查服务器的版本号?

    在 shell 中,试试这个:

    use admin
    db.runCommand( {buildInfo: 1} )
    

    【讨论】:

    • 我猜是的。当我运行你的命令时我得到了这个: db.runCommand( {buildInfo: 1} ) { "version" : "2.2.1", "versionArray" : [ 2, 2, 1, 0 ], }
    • 看起来不错。您确定它与您的应用所连接的实例相同?
    • 我的系统中安装了两个版本的 MongoDB,我错误地启动了我的旧版本。谢谢
    【解决方案2】:

    发现了错误。我在 MongoDB Java 驱动程序上使用 2.9 版本。当我将它升级到 2.10 时,它运行良好。谢谢大家:)

    【讨论】:

      【解决方案3】:

      我遇到了同样的错误“没有这样的 cmd:聚合”,我从默认的 debian 存储库尝试了新版本的 mongodb 2.4、2.6,但总是收到此错误。

      之后从 mongo repo 安装了 mongodb-org-server 并且它工作了 http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-15
        • 1970-01-01
        相关资源
        最近更新 更多