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 ?
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} )
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 :)
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/
Related
Is there a way we can set internalQueryMaxAddToSetBytes in mongdb version 3.6.9 ? The admin command db.adminCommand({setParameter: 1, internalQueryMaxAddToSetBytes: newLimit}) is not supported in 3.6.9.
I got below error message
"errmsg" : "attempted to set unrecognized parameter [internalQueryMaxAddToSetBytes], use help:true to see options "
How can we configure this for 3.6.9?
Related - https://jira.mongodb.org/browse/SERVER-44869
https://jira.mongodb.org/browse/SERVER-44174
Per the server ticket this feature requires 3.6.17 or newer server.
{ "ok" : 0,
"errmsg" : "The featureCompatibilityVersion must be 3.6 to create a collection validator using 3.6 query features. See http://dochub.mongodb.org/core/3.6-feature-compatibility.",
"code" : 224,
"codeName" : "QueryFeatureNotAllowed"
}
The Above is the error in MongoDB.
Version - 3.6.2;
OS: Ubuntu 16.0.4;
Thank you guys for trying to answer my question but I solved the issue myself.
For me the solution was to execute the following command:
db.adminCommand({setFeatureCompatibilityVersion: "3.6"})
when I run this aggregation pipeline in Robomongo
db.getCollection('xyz').aggregate([{$match: {tyu: "asd", ghj: "qwe"}},
{$sample: {size: 5}}])
I receive this error:
assert: command failed: {
"errmsg" : "exception: Unrecognized pipeline stage name: '$sample'",
"code" : 16436,
"ok" : 0
I'm using mongodb ver 3.2.6 and since $sample is supported from 3.2 onward.
(https://docs.mongodb.com/manual/reference/operator/aggregation/sample/#pipe._S_sample)
Im a little confused as to why I receive this error message.
Maybe I'm just missing something small.
Thanks
As stated in the comments of the question. Mongo client had a version of 3.2.6 but Mongo db had a version of 3.0.6.
I used version() in the shell to get the client's version and
db.version() to get the DB's version.
ver 3.0.6 is too low to support $sample as stated in the mongo documentation
https://docs.mongodb.com/manual/reference/operator/aggregation/sample/#pipe._S_sample
MongoDB shell version: 2.1.0
$near operator works fine. But as I try (in mongodb shell and nodejs):
db.locations.find({loc: {$near:[50,50],$maxDistance:50}})
error: { "$err" : "invalid operator: $maxDistance" }
I tried upgrading mongodb (if you know an easy way to do this I would really really thank you as I had a lot of trouble with trying to shut down the server in order to replace the bin folder...)
Thank you!
upgrading mongodb solved the problem. 10x!
There is a problem about Mongodb.Our version is MongoDB version 1.6.4.
Yesterday I had to kill mongodb process in our 64 bit linux machine.
Then queries were running so long time.
I checked with;
mongod --repair or ->db.repairDatabase() command and I checked repair with
->db.users.validate();
the result must be "...."result" : " validate"..." but,
returns : { "errmsg" : "ns not found", "ok" : 0, "valid" : false }
How can I fix this error message ?
Maybe try check this comment. But it can be probably hard to solve problem and it is easier to start over as suggested here.
I suggest to upgrade mongodb to 1.8.x and start it with --journal option. No more repairs should be needed then;)