I’m also looking for some guidance on limiting a trigger based on the update belonging to a specific field of a subdocument. In my case the Match Expression works if I’m matching on a specific value but fails with more complex operators.
Does Not Work: {"updateDescription.updatedFields":{"participation.2021.0.status":{"$exists":true}}}
Also Does Not Work: {"updateDescription.updatedFields":{"participation.2021.0.status":{"$eq":"accepted"}}}
It would be great to get some more detailed information on how Trigger Match Expressions are evaluated and what sort of limitations / workarounds there are.
Update with solution, thanks to some help from MongoDB Support.
Because of the vagaries of how the change stream is formatted, it’s non-trivial to get a trigger to fire on any change to a particular nested field. This general structure, however, worked for me in the trigger’s match expression: