I am trying to create a new computed field using the $project stage (Called X) and then use it to filter on its value in the $match stage but the the db look for my new computed field X in the document structure and of course doesn’t find it since it is just generated on the runtime inside the $project. hence the $match condition fails and the query returns no results.
is there any workaround to filter on a computed field (create a field in $project stage and use it in $match stage)?
Note: I tried commuting the field inside the $match stage and skip the $project stage but it doesn’t work. the query throws an error.