1db.collection.aggregate([
2 {
3 $addFields: {
4 nameFilter: {
5 $concat: ["$name", " ", "$surname"],
6 },
7 locationFilter: {
8 $concat: ["$workplace", " ", "$location"],
9 },
10 },
11 },
12 {
13 $match: {
14 nameFilter: {
15 $regex: req.query.name,
16 $options: "i",
17 },
18 locationFilter: {
19 $regex: req.query.place,
20 $options: "i",
21 },
22 },
23 },
24]);