Test and refactor Event#search.

Test and refactor SQL search engine implementation of Event#search. This lays the groundwork for eventual object extraction.
It's really unfortunate that ActiveRecord doesn't have first-class support for ORs.