In my pipeline I’m trying to connect documents that have a deeply nested values that I wanted to get on top by saving then in new added fields. But since they are stored inside multidimensional arrays I’m unable to get them thu numeric indexes.
Not sure what am i doing wrong:
db.OrderAttributes.aggregate([
{
$lookup:
{
from: "Orders",
localField: "OrderId",
foreignField: "OrderId",
as: "orderdata"
}
},
{
$match:{
RulesetInfluencedAttributes: {$elemMatch: {
LexisAttributes:{$elemMatch: {
"myattributes.myvalue":{$ne:null}
}
}
}}
}
},
{
$addFields: {
test: "$RulesetInfluencedAttributes.0.LexisAttributes.0.myattributes.myvalue" <-- this returns empty array
}}
}
},