Database
db={company:[{company_id:1,hubId:4,dimensions:{region:["North america"],country:["USA"]},name:"Amsol Inc."},{company_id:1,hubId:4,dimensions:{region:["North america"],country:["Canada","Greenland"]},name:"Amsol Inc."},{company_id:2,hubId:7,dimensions:{region:"North america",country:"USA",revenue:34555},name:"Microsoft Inc."}],reports:[{report_id:1,name:"example report",hubId:4,dimensions:{region:"North america",country:"USA"},/**name:'Amsol Inc.'*/},{report_id:2,name:"example report",hubId:4,dimensions:{region:"North america",country:"Canada"},/**name:'Amsol Inc.'*/},{report_id:3,name:"example report",hubId:5,dimensions:{region:"North america",country:"USA",revenue:20000},/**name:'Microsoft Inc.'*/},{report_id:4,name:"example report",hubId:4,dimensions:{region:"North america",country:"Greenland"},/**name:'Amsol Inc.'*/}]}
Query
db.reports.aggregate([{$lookup:{from:"company",let:{hubId:"$hubId",dimensionsCountry:"$dimensions.country",dimensionsRegion:"$dimensions.region"},as:"companies",pipeline:[{$match:{$expr:{$and:[{$eq:["$hubId","$$hubId"]},{$in:["$$dimensionsRegion","$dimensions.region"]},{$in:["$$dimensionsCountry","$dimensions.country"]}]}}},{$project:{"_id":1}}]}},{$match:{$expr:{$gt:[{$size:"$companies"},0]}}}])