Wondering how a $lookup paired with $search would work. I’m expecting the following to return something, but it doesn’t. However, hard coding the query does work.
db.getCollection('recipes').aggregate([
{
$match: {}
},
{
$unwind: "$ingredients"
},
{
$lookup: {
let: { ingredient_name: "$ingredients.name" },
from: "products",
as: "product",
pipeline: [
{
$search: {
index: "products",
text: {
query: "$$ingredient_name",
path: {
wildcard: "*"
}
}
}
},
{
$limit: 1
}
]
}
}