I would like to output the result of a $lookup depending on the content of the “looked up” document. How can this be done?
$lookup: {
from: "device_instances",
let: { path_regex: {$concat: ["^", "$path"]}, device_category: { $concat: ["catecories.","$category"]}},
pipeline: [{
$match: {
$expr: {
$regexMatch: {
input: "$path",
regex: "$$path_regex",
options: "i"
}
}
}
}],
as: "$$device_category"
}