Refactor part of searcher into sql string