Database

[{"comments":[1,2,3,4,5,6,7,8,9,0]},{"comments":[1,2,3,4,5,6,7,8,9,0]}]

Query

db.collection.aggregate([{$project:{comments:{$slice:["$comments",{$cond:[{$gte:[{$size:"$comments"},15]},-15,99999]},5]}}}])

Result