title: MongoDb $addFields and $match
body: <p>In my mongodb query, I use $addFields to add ID field which concatenated of other three fields.   My problem is that I get no result if I $match that new added field with value that I want to query. For other fields, they work just fine.   </p>
  
  <p><a href="https://i.stack.imgur.com/Hh1Lu.jpg" rel="noreferrer"> order of aggregation</a></p>
  
  <p><a href="https://i.stack.imgur.com/v2rXf.jpg" rel="noreferrer">what is in aggregation</a></p>
  
  <pre><code>data = await model.aggregate([
              {
                  $project: {
                      projectName: 1,
                      price: 1,
                      'document': '$$ROOT'
                  }
              },
              {
                  $addFields:{
                      'document.id': {$concat: ['$document.propertyId.prefix','$document.propertyId.number']}
                  }
              },
              {
                  $match: {
                      $and: [
                          {
                              $or: [
                                  {id: {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                                  {projectName: {$regex: '.*' + req.query.search + '.*', $options: "i"}},
  
                                  /*This also doesnt work*/
                                  // {'document.id': {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                                  // {'document.projectName': {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                              ]
                          }
                      ]
                  }
              },
              {
                  $replaceRoot: {newRoot: "$document"}
              },
              {
                  $sort: {
                      [sortBy]: sortType
                  }
              },
          ]);
  </code></pre>