Referencing a doc field in the $elemMatch criteria value in the projection

A sample query (for the sample data provided below)
db.modelA.find ( { “relations.grpId”: “Rebels” }, { “name”: 1, controllers: { $elemMatch: { qKey: relations.relevancy } } } )

How can I dynamically refer to a field value in the above $elemMatch in projection clause.

Sample data

db.modelAA.insertOne({"_id": “1234”, “name”: “Chewbacca”, “controlKeys”: [“C012”, “M088”], “controllers”: [{“qKey”: “C012”, “status”: “Active”, “autoPay”: true, “amtDue”: 20}, {“qKey”: “M088”, “status”: “Active”, “autoPay”: false, “amtDue”: 60}], “relations”: [{“basis”: “motto”, “grpId”: “Rebels”, “relevancy”: “M088”}] })

db.modelAA.insertOne({"_id": “6789”, “name”: “Luke Skywalker”, “controlKeys”: [“C977”, “M977”], “controllers”: [{“qKey”: “C977”, “status”: “Inactive”}, {“qKey”: “M977”, “status”: “Active”, “autoPay”: true, “amtDue”: 55}], “relations”: [{“basis”: “motto”, “grpId”: “Rebels”, “relevancy”: “M977”}, {“basis”: “clan”, “grpId”: “Jedi”, “relevancy”: “C977”}] })

db.modelAA.insertOne({"_id": “AB7R”, “name”: “Han Solo”, “controlKeys”: [“M177”], “controllers”: [{“qKey”: “M177”, “status”: “Active”, “autoPay”: true, “amtDue”: 35}], “relations”: [{“basis”: “motto”, “grpId”: “Rebels”, “relevancy”: “M177”}, {“basis”: “clan”, “grpId”: “Jedi”, “relevancy”: “M177”}] })

Please read Formatting code and log snippets in posts and update your sample documents so we can cut-n-paste into our systems.

If that projection can be done within find() it will probably involve $expr with $$ROOT to refer to fields outside the controllers array. But since relations is also an array I am not too sure. In particular, with _id:6789 where you have 2 qKey matching relevancy.

I think the change are better with a $project aggregation with $map on controllers.