Added functionality to actually query the database on a search.