Database
[{"collection":"collection","count":97,"content":{"_id":{"type":"autoincrement","autoType":"int"},"res":{"type":"enum","values":[10,15,28,35,36,36,37,38,39,39,39,40,40,40,41,41,41,41,41,42,42,43,43,44,44,44,46,46,46,46,47,47,47,47,47,47,47,47,48,48,48,49,49,49,49,49,50,51,51,52,52,52,53,53,53,53,53,54,54,55,55,56,56,56,56,56,56,57,57,57,57,58,58,58,58,59,59,59,60,60,60,60,60,61,61,61,63,64,65,65,66,66,67,67,67,73,99]}}}]
Query
db.collection.aggregate([{$setWindowFields:{sortBy:{res:1},output:{totalCount:{$count:{}},index:{$sum:1,window:{documents:["unbounded","current"]}}}}},{$match:{$expr:{$lte:[{$abs:{$subtract:[{$mod:[{$multiply:[{$add:["$index",{$round:{$divide:["$totalCount",4]}}]},2]},"$totalCount"]},0]}},1]}}},{$group:{_id:null,res:{$push:"$res"}}},{$project:{_id:0,q1:{$first:"$res"},q3:{$last:"$res"},iqr:{"$subtract":[{$last:"$res"},{$first:"$res"}]}}},{$project:{outlierThresholdLower:{$subtract:["$q1",{$multiply:["$iqr",1.5]}]},outlierThresholdUpper:{$add:["$q3",{$multiply:["$iqr",1.5]}]}}},{$lookup:{from:"collection",as:"outliers",let:{oTL:"$outlierThresholdLower",oTU:"$outlierThresholdUpper"},pipeline:[{$match:{$expr:{$or:[{$lt:["$res","$$oTL"]},{$gt:["$res","$$oTU"]}]}}},{$project:{_id:1}}]}}])