Refactor common code into separate search function, add in aliases for doctypes