refactor search and join where clauses with OR instead of AND