Database

[{_id:"id1",from:ISODate("2023-01-21T06:30:00.000Z"),to:ISODate("2023-01-21T18:30:00.000Z"),matchStatus:0,matchId:null,userId:"userId1",organisationId:"organisationId1",location:"Chertsey",type:"DCA",offers:[{from:ISODate("2023-01-23T05:00:00.000Z"),to:ISODate("2023-01-24T07:00:00.000Z"),locations:["Chertsey","Walton"],types:["DCA","SRV"],}]},{_id:"id2",from:ISODate("2023-01-23T06:30:00.000Z"),to:ISODate("2023-01-23T18:30:00.000Z"),matchStatus:0,matchId:null,userId:"userId2",organisationId:"organisationId2",location:"Chertsey",type:"DCA",offers:[{from:ISODate("2023-01-21T05:00:00.000Z"),to:ISODate("2023-01-21T07:00:00.000Z"),locations:["Chertsey","Walton"],types:["DCA","SRV"],}]}]

Query

db.collection.aggregate([{$match:{organisationId:"organisationId1",matchId:null,matchStatus:0}},{$unwind:"$offers"},{"$lookup":{"from":"collection","let":{offersFrom:"$offers.from",offersTo:"$offers.to",offersLocation:"$offers.locations",offersType:"$offers.types"},"pipeline":[{$match:{$expr:{$and:[{$gte:["$from","$$offersFrom"]},{$lte:["$to","$$offersTo"]},{"$in":["$location","$$offersLocation"]},{"$in":["$type","$$offersType"]},]}}}],"as":"selfLookup"}},{"$unwind":"$selfLookup"},{"$replaceRoot":{"newRoot":"$selfLookup"}}])

Result