refactor search history logic so we're pulling search query parameters out of the database, not the session.