make search feature

Could we move this SQL into a method on the model?