Hmm without much testing on my end I will say you can use $cmp
for this:
http://docs.mongodb.org/manual/reference/aggregation/cmp/#_S_cmp
db.test.aggregate([
{$project: {
// All your other fields here
cmp_value: {$cmp: ['$a', '$b']}
}},
{$match: {cmp_value: {$gt: 0}}}
])
There might be a better way but I haven’t got a MongoDB installation near me to test.