Basically, the top level $reduce $add (using $cond) 0 if the jobId does not match but $add the inner most $reduce if it does.
{
$project: {
"totale": {
"$reduce": {
input: "$sessioniControllo" ,
initialValue: 0 ,
in: {
$add: [ "$$value",
{ "cond" : [
{ "$ne" : [ "$$this.jobId", Long("18453") ] } ,
0 ,
{ "$reduce" : {
input: "$$this.errori" ,
initialValue: 0 ,
in: {
$add: [ "$$value" , { $size: "$$this.risultatoOperazione" } ]
}
} }
] }
]
}
}
}
}
}