db.getCollection('experiment_scopes').aggregate( [ { $match: {_id: "c45_v[5-45]_1"} }, { $unwind: "$instances" }, { $project: {"instance_id": "$instances"} }, { $lookup: { from: "wmis_qubos", localField: "instance_id", foreignField: "instance", as: "wmis_qubo" } }, { $unwind: "$wmis_qubo" }, { $lookup: { from: "embeddings", let: { qubo_id: "$wmis_qubo._id", solver_graph_id: ObjectId("5c9e13168c6fe628c16eb361") }, pipeline: [ { $match: { $expr: { $and: [ {$eq: ["$qubo", "$$qubo_id"]}, {$eq: ["$solver_graph", "$$solver_graph_id"]} ] } } }, { $project: { embeddings: true } } ], as: "embeddings" } }, { $match: {embeddings: {$exists: true, $not: {$size: 0}}} }, { $unwind: "$embeddings" }, { $project: { _id: false, instance_id: true, wmis_qubo: true, embeddings: "$embeddings.embeddings" } } */ ])