0

我有两个系列

集合1

{
    _id: ObjectId("5ba27d02d579d8cd47a02408"),
    NAME: "xxxx",
    DESC: "xxxxxx"
}

集合2

{
    _id: ObjectId("5ba2900dd579d8cd47a026b7")
    COLLECTION1_ID: "5ba27d02d579d8cd47a02408"
    ORDER: 5
}

我正在尝试使用以下代码加入这两个集合,但它似乎不起作用,我缺少什么吗?我在 Spring boot 和 maven 版本 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>());
4

0 回答 0