Database

[{"method":1,"item":1,"rank":1},{"method":2,"item":1,"rank":2},{"method":3,"item":1,"rank":3},{"method":4,"item":1},{"method":5,"item":1},]

Query

db.collection.aggregate([{$match:{item:1}},{$group:{_id:"$item",max:{$max:"$rank"},data:{$push:"$$ROOT"}}},{$unwind:"$data"},{$match:{$expr:{$or:[{$eq:[{$type:"$data.rank"},"missing"]},{$eq:["$data.rank","$max"]}]}}},{$replaceWith:"$data"}])

Result