Database
db={"vulns":[{"_id":1,"advisoryId":"44444"},{"_id":2,"advisoryId":"55555"},{"_id":3,"advisoryId":"66666"}],"tracker":[{"_id":1,"customerId":"12345","advisory":{advisoryId:"44444"}},{"_id":2,"customerId":"12345","advisory":{advisoryId:"55555"}},{"_id":3,"customerId":"12456","advisory":{advisoryId:"55555"}}]}
Query
db.tracker.aggregate([{"$match":{/** specific customerId*/"customerId":"12345"}},{/** make array of all unique advisory.advisoryId's*/"$group":{"_id":null,"notAdvIds":{"$addToSet":"$advisory.advisoryId"}}},{/** go find the vulns not in the array*/"$lookup":{"from":"vulns","let":{"notAdvIds":"$notAdvIds"},"as":"vulns","pipeline":[{"$match":{"$expr":{"$not":{"$in":["$advisoryId","$$notAdvIds"]}}}}]}},/** just output formatting from here*/{/** create separate doc for each vuln*/"$unwind":"$vulns"},{/** make doc just the vuln*/"$replaceWith":"$vulns"}])