Database

[{"collection":"ranking","count":20,"content":{"_id":{"type":"autoincrement","autoType":"int","startInt":0},"score":{"type":"int","minInt":-100,"maxInt":500},"update":{"type":"boolean"},"rank":{"type":"int","minInt":0,"maxInt":100}}}]

Query

db.ranking.aggregate([{"$setWindowFields":{"partitionBy":"$update","sortBy":{"score":-1},"output":{"rank":{"$denseRank":{}}}}},{"$set":{"rank":{"$cond":["$update","$rank",0]}}},{"$match":{"$expr":{"$not":[{"$and":["$update",{"$lte":["$score",0]}]}]}}},{"$merge":"ranking"}])

Result