You can use $expr which allows the use of aggregation expressions within the query language.
db.collection.find({ "$expr": { "$eq": [ "$_id" , "$md5" ] } })
or with aggregation
db.collection.aggregate([
{ "$match": { "$expr": { "$eq": [ "$_id" , "$md5" ] } } }
])