Aggregation:com.mongodb.MongoCommandException: Command failed with error 16436: -
i using mongodb , wanted store log data in form array in document. while reading collection using aggregation pipe line. when tired use query in mongo booster, query working fine giving following exception when tried use java program.
details: --> db.version() - 3.2.7 --> mongo-java_driver: 3.2.2
query in mongo booster: ======================= db.logcollection.aggregate({$unwind:'$loglist'},{ $sort : {'loglist.log.timestamp': -1} },{ $match:{'loglist.log.userid': "100100"}},{ $group: {_id: null, loglist: {$push: '$loglist'}}},{ $project: { _id: 0,loglist: {log:{timestamp: 1,operation:1}}}}).pretty() query: using java ================= dbobject unwindfield = new basicdbobject("$unwind", "$loglist"); dbobject groupfields = new basicdbobject("_id", null); groupfields.put("loglist", new basicdbobject("$push","$loglist")); dbobject group = new basicdbobject("$group", groupfields); db logdb = mongoclient.getdb("logdb"); dbcollection collection=logdb.getcollection(collectionname); dbobject skipfields = new basicdbobject("$skip",skip); dbobject limitfields = new basicdbobject("$limit",limit); iterable<dbobject> results =null; try { results= collection.aggregate(unwindfield, sortfield,searchfield,skipfields,limitfields,group,projectfields).results(); } catch (exception e) { log.error("readlogsfromcollection() failed"); } exception: ========== com.mongodb.mongocommandexception: command failed error 16436: 'unrecognized pipeline stage name: 'loglist.log.timestamp' on server localhost:27017. full response { "ok" : 0.0, "errmsg" : "unrecognized pipeline stage name: 'loglist.log.timestamp'", "code" : 16436 } input document: ================ { "loglist" : [ { "log" : { "acctid" : "0", "info1" : { "itemname" : "-", "value" : "-" }, "errorcode" : "", "internalinformation" : "", "kind" : "infomation", "groupid" : "0", "logid" : "g1_1", "operation" : "startdiscovery", "result" : "normal", "userid" : "100100", "timestamp" : "1470980265729" } } ] } could body tell me might problem, read issue version, used mongo-java_driver-3.3 no use.
thanks in advance.
here java code below mongodb query. have used same java driver (mongo-java_driver: 3.2.2) mentioned in op.
mongodb query:-
db.loglist.aggregate({$unwind:'$loglist'}, { $sort : {'loglist.log.timestamp': -1} }, { $match:{'loglist.log.userid': "100100"}}, { $group: {_id: null, loglist: {$push: '$loglist'}}}, { $project: { _id: 0,loglist: {log:{timestamp: 1,operation:1}}}}).pretty(); java code:-
public static void main(string[] args) { mongoclient client = new mongoclient(); mongodatabase database = client.getdatabase("test"); aggregateiterable<document> mongocollectionlist = database.getcollection("loglist") .aggregate(arrays.aslist(aggregates.unwind("$loglist"), aggregates.sort(sorts.descending("loglist.log.timestamp")), aggregates.match(filters.eq("loglist.log.userid", "100100")), aggregates.group("$id", accumulators.push("loglist", "$loglist")), aggregates.project(projections.include("loglist.log.timestamp", "loglist.log.operation")) )); mongocursor<document> mongocursor = mongocollectionlist.iterator(); while (mongocursor.hasnext()) { system.out.println(mongocursor.next().tojson()); } } output:-
{ "_id": null, "loglist": [{ "log": { "operation": "startdiscovery", "timestamp": "1470980265729" } }] }
Aggregation:Com.Mongodb.Mongocommandexception: Command Failed With
ReplyDeleteError 16436: - >>>>> Download Now
>>>>> Download Full
Aggregation:Com.Mongodb.Mongocommandexception: Command Failed With
Error 16436: - >>>>> Download LINK
>>>>> Download Now
Aggregation:Com.Mongodb.Mongocommandexception: Command Failed With
Error 16436: - >>>>> Download Full
>>>>> Download LINK DZ