Generalizing and sanitizing rank searching