Драйвер MongoDB Java: такога cmd: aggregate няма (MongoDB Java driver : no such cmd: aggregate)


問題描述

Драйвер MongoDB Java: такога cmd: aggregate няма (MongoDB Java driver : no such cmd: aggregate)

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/

(by sharathpaulmelnikowsharathBorislav Gizdov)

參考文件

  1. MongoDB Java driver : no such cmd: aggregate (CC BY‑SA 3.0/4.0)

#mongodb-java #mongoDB #mongodb-query






相關問題

GridFS Java 對像是線程安全的嗎? (Are GridFS Java objects thread safe?)

Драйвер MongoDB Java: такога cmd: aggregate няма (MongoDB Java driver : no such cmd: aggregate)

Стварэнне парадкавага нумара ў mongoDB (Generating sequence number in mongoDB)

MongoDB java驅動如何判斷副本集是否處於自動故障轉移過程中? (How can MongoDB java driver determine if replica set is in the process of automatic failover?)

優化 mongodb 中的查詢 (Optimising queries in mongodb)

查詢數據時應該使用 MongoTemplate 還是 DBCollection (Should i use MongoTemplate or DBCollection when query data)

org.bson.codecs.configuration.CodecConfigurationException:找不到類 [Ljava.lang.String; 的編解碼器; (org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class [Ljava.lang.String;)

如何使用 Java MongoDB 驅動程序檢索字段子集? (How to retrieve a subset of fields using the Java MongoDB driver?)

當使用 karras 和 clojure 給出字段時,如何更新 MongoDB 中的文檔? (How to update a Document in MongoDB when a field is given with karras & clojure?)

如何使用 java 代碼轉換 mongodb 查詢 (How to Transform mongodb query using java code)

MongoDB 文檔使用 Java 中的 findOneAndUpdate 方法更新數組元素 (MongoDB document update array element using findOneAndUpdate method in Java)

aws documentdb 是否為兩種方式的 ssl 驗證 mongodb 客戶端證書? (Does aws documentdb validate mongodb client certificate for two way ssl?)







留言討論