MongoDB Java driver : no such cmd: aggregate

北慕城南 提交于 2020-01-05 05:50:10

问题


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

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

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" : .... }

Any clue why ?


回答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?

From the shell, try this:

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



回答2:


figured out the error. I was using the 2.9 version on the MongoDB Java driver. When I upgraded it to 2.10, it worked perfectly. Thanks folks :)




回答3:


I had the same error "no such cmd: aggregate", and I tried new version of mongodb 2.4,2.6 from default debian repositories and always receiving this error.

After that installed mongodb-org-server from mongo repo and it worked http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/



来源:https://stackoverflow.com/questions/13695851/mongodb-java-driver-no-such-cmd-aggregate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!