We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any solution for the above issue?
I have a similar issue here
My query on Mongo Shell is like -
db.getCollection('cm').aggregate([ { "$match": { "ID": "2006"} }, { "$lookup": { "from": "cm", "localField": "Parent", "foreignField": "_id", "as": "bList" } }, {"$unwind":"$bList"}, { "$lookup": { "from": "cm", "localField": "bList.Parent", "foreignField": "_id", "as": "bList1" } }, {"$unwind":"$bList1"}, { $project: { "_id": 0, "DivisionId": "$bList.Parent", "GroupID": "$bList._id", "GroupName": "$bList.Name", "DivisionName":"$bList1.Name" } } ])
JSON document 1: - { "_id" : "ProductGroup2006", "Parent" : "Group6", "Ancestors" : [ "Division2", "Group6" ], "ID" : "2006" }
{ "_id" : "ProductGroup2006", "Parent" : "Group6", "Ancestors" : [ "Division2", "Group6" ], "ID" : "2006" }
JSON document 2: { "_id" : "Division2", "Parent" : "", "Ancestors" : [], "Name" : "Sujay Godbole", "Type" : "Division" }
{ "_id" : "Division2", "Parent" : "", "Ancestors" : [], "Name" : "Sujay Godbole", "Type" : "Division" }
JSON Document 3 { "_id" : "Group6", "Parent" : "Division2", "ID" : "6", "Ancestors" : [ "Division2" ], "Name" : "Chirag Mehta" }
{ "_id" : "Group6", "Parent" : "Division2", "ID" : "6", "Ancestors" : [ "Division2" ], "Name" : "Chirag Mehta" }
After adding all these documents to the Collection in JUNIT class, call the below:
`List aggregation = new ArrayList(); aggregation.add(Aggregates.match(Filters.eq("ID", "2006"))); aggregation.add(Aggregates.lookup("cm", "Parent", "_id", "siblingList")); aggregation.add(Aggregates.unwind("$siblingList")); aggregation.add(Aggregates.lookup("cm", "siblingList.Parent", "_id", "ancestorList")); aggregation.add(Aggregates.unwind("$ancestorList"));
aggregation.add(Aggregates.project( new Document("_id", 0).append("DivisionId", "$siblingList.Parent").append("GroupId", "$siblingList._id") .append("GroupName", "$siblingList.Name").append("DivisionName", "$ancestorList.Name")));`
Finally - AggregateIterable<Document> iterable = mongoCollection.aggregate(aggregate);
AggregateIterable<Document> iterable = mongoCollection.aggregate(aggregate);
And this action results in EMPTY objects
ISSUE: My main() works and returns results; but the same in Fongo - collection.aggregate(), return EMPTY results.
Any help/resolution appreciated
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Any solution for the above issue?
I have a similar issue here
My query on Mongo Shell is like -
JSON document 1: -
{ "_id" : "ProductGroup2006", "Parent" : "Group6", "Ancestors" : [ "Division2", "Group6" ], "ID" : "2006" }
JSON document 2:
{ "_id" : "Division2", "Parent" : "", "Ancestors" : [], "Name" : "Sujay Godbole", "Type" : "Division" }
JSON Document 3
{ "_id" : "Group6", "Parent" : "Division2", "ID" : "6", "Ancestors" : [ "Division2" ], "Name" : "Chirag Mehta" }
After adding all these documents to the Collection in JUNIT class, call the below:
`List aggregation = new ArrayList();
aggregation.add(Aggregates.match(Filters.eq("ID", "2006")));
aggregation.add(Aggregates.lookup("cm", "Parent", "_id", "siblingList"));
aggregation.add(Aggregates.unwind("$siblingList"));
aggregation.add(Aggregates.lookup("cm", "siblingList.Parent", "_id", "ancestorList"));
aggregation.add(Aggregates.unwind("$ancestorList"));
Finally -
AggregateIterable<Document> iterable = mongoCollection.aggregate(aggregate);
And this action results in EMPTY objects
ISSUE: My main() works and returns results; but the same in Fongo - collection.aggregate(), return EMPTY results.
Any help/resolution appreciated
The text was updated successfully, but these errors were encountered: