Result filtering on search (also known as Partial Search)

First take at refactoring search to allow selective results, rather than returning the whole thing.
You don't need this check both in search and in do_search