Move the search logic into a search repository.