Pencarian lumpur menggabungkan bidang

db.collection.aggregate([
  {
    $addFields: {
      nameFilter: {
        $concat: ["$name", " ", "$surname"],
      },
      locationFilter: {
        $concat: ["$workplace", " ", "$location"],
      },
    },
  },
  {
    $match: {
      nameFilter: {
        $regex: req.query.name,
        $options: "i",
      },
      locationFilter: {
        $regex: req.query.place,
        $options: "i",
      },
    },
  },
]);
Duck Duck Go-ogle