MongoDB Java驱动程序:无此类cmd:聚合 [英] MongoDB Java driver : no such cmd: aggregate

查看:65
本文介绍了MongoDB Java驱动程序:无此类cmd:聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码中将MongoDB聚合函数称为:

I am calling the MongoDB aggregate function in my code as :

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

我已经在本地主机上测试了我的代码,它可以完美运行.当我在另一个数据库(2.2.1版)中使用相同的文件时,会出现此错误:

I have tested my code in my localhost, and it works perfect. When I am using the same in another DB (version 2.2.1), it gives this error :

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

任何线索为什么?

推荐答案

基于我对类似问题所见的其他答案,服务器很可能实际上并不是您所相信的2.2.1.

Based on other answers I've seen to similar questions, it seems most likely that the server is not actually 2.2.1 as you believe.

您如何查看服务器的版本号?

How are you checking the server's version number?

在shell中,尝试以下操作:

From the shell, try this:

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

这篇关于MongoDB Java驱动程序:无此类cmd:聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆