title: "InvalidPipelineOperator" with '$regex'
body: <p>I am using MongoDB aggregation pipeline to filter my data based on a name. But when I run the code below, it shows an error which I have not been able to crack.</p>
  
  <p>I have a model Employee with name, gender, department, and age as their fields.</p>
  
  <pre><code>    filter = {};
      filter.$and = [];
  
      filter.$and.push( {
              name: { $regex: '(?i)' + fname + '.*' }
          }
  
      Employee.aggregate([
      {
          $match: 
          {
              $expr: filter
          }
      }
      )].exec((err, result) =&gt; {
      if (err) res.json({ success: false, msg: err });
      else {
          res.json(result);
      }
  });
  </code></pre>
  
  <p>It gives an error:</p>
  
  <pre><code>{
    "success":false,
    "msg":
         {
          "ok":0,
          "errmsg":"Unrecognized expression '$regex'",
          "code":168,
          "codeName":"InvalidPipelineOperator",
          "name":"MongoError"
         }
   }
  </code></pre>