Lab: using $lookup having issues with command (spoilers)

Having trouble getting the $lookup command to work. Have messed around with regex and this is the only one I can get to work. It gives me results false or true though and I don’t know how to count only the trues. The lookup operator is giving me syntax error repeatedly. Also, I have no idea how to blur this post out as a spoiler.

db.air_routes.aggregate([

{ $addFields: { result: { $regexMatch: { input: "$airplane", regex: /747|380/}}}}, { $sort: { result: -1}},
  { 
    $lookup: 
    {
     from: “air_alliances”,
     localField: “airline.name”,
     foreignField: “airlines”,
     as: “alliance”
}
},
{
$unwind: “$alliance”
}])

HI @Douglas_Sourile , as far as I can see there is no syntax error in your $lookup stage, but seems like the quotes(“”) that you are using are marked as invalid inside the mongo shell.
I would recommend you to replace the current quotes from (“”) to (""), and hopefully, this will fix the issue.
Also, replace the same for your $unwind stage as well.

db.air_routes.aggregate([

{ $addFields: { result: { $regexMatch: { input: "$airplane", regex: /747|380/}}}}, { $sort: { result: -1}},
  { 
    $lookup: 
    {
     from: "air_alliances",
     localField: "airline.name",
     foreignField: "airlines",
     as: "alliance"
    }
  },
  {
    $unwind: "$alliance"
  }
])

Also, to blur your code/potential-answers, you can enclose the same as following:

[spoiler] <---Your code here---> [/spoiler]

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

Because, the output of https://docs.mongodb.com/manual/reference/operator/aggregation/regexMatch/ is a boolean.

For this specific problem I think that what you want is to only match the one that matches the expression. A simple $match stage with https://docs.mongodb.com/manual/reference/operator/query/regex/ should be sufficient.