How to use $regex inside $or as an Aggregation Expression
I have a query which allows the user to filter by some string field using a format that looks like: "Where description of the latest inspection is any of: foo or bar " . This works great with the following query: db.getCollection('permits').find({ '$expr': { '$let': { vars: { latestInspection: { '$arrayElemAt': ['$inspections', { '$indexOfArray': ['$inspections.inspectionDate', { '$max': '$inspections.inspectionDate' }] }] } }, in: { '$in': ['$$latestInspection.description', ['Fire inspection on property', 'Health inspection']] } } } }) What I want is for the user to be able to use wildcards