I have a two collections
Collection1
{
_id: ObjectId("5ba27d02d579d8cd47a02408"),
NAME: "xxxx",
DESC: "xxxxxx"
}
Collection2
{
_id: ObjectId("5ba2900dd579d8cd47a026b7")
COLLECTION1_ID: "5ba27d02d579d8cd47a02408"
ORDER: 5
}
I'm trying to join both the collections using the following code but it doesnt seem to work, is there something I am missing? I'm doing this on Spring boot and maven version 3.7.0
MongoDatabase database = mongo.getDatabase("ngdesk");
MongoCollection<Document> collection =
database.getCollection("Collection1");
ArrayList<Bson> filters = new ArrayList<Bson>();
filters.add(Aggregates.lookup("Collection2", "_id", "COLLECTION1_ID", "TEST"));
List<Document> testList = collection.aggregate(filters).into(new ArrayList<Document>());