Database
db={"collection1":[{_id:ObjectId("6253492b634e9f3970c5dc86"),ID:90448,Name:"Hostname1",Identifier:"hostname_example1"},{_id:ObjectId("6253492b634e9f3970c5dc87"),ID:66062,Name:"Hostname2",Identifier:"hostname_example2"},{_id:ObjectId("6253492b634e9f3970c5dc88"),ID:56415,Name:"Hostname3",Identifier:"hostname_example3"},{_id:ObjectId("6253492b634e9f3970c5dc89"),ID:84576,Name:"Hostname4",Identifier:"hostname_example4"}],"collection2":[{_id:ObjectId("625350ff09043895b2c3b2d3"),flowSourceType:"Unix",flowHostname:"flowHostname1",flowIPd:"11.11.11.11"},{_id:ObjectId("625350ff09043895b2c3b2d4"),flowSourceType:"Unix",flowHostname:"hostname_example2",flowIPd:"12.12.12.12"},{_id:ObjectId("625350ff09043895b2c3b2d5"),flowSourceType:"Unix",flowHostname:"hostname_example3",flowIPd:"13.13.13.13"},]}
Query
db.collection2.aggregate([{"$lookup":{"from":"collection1","let":{f:"$flowHostname"},pipeline:[{"$match":{$expr:{$or:[{$eq:["$$f","$Identifier"]},{$ne:[{"$indexOfCP":["$Identifier","$$f"]},-1]}]}}},{$limit:1}],"as":"col1Lookup"}},{"$unwind":"$col1Lookup"},{"$unset":"col1Lookup"}])