Move the query creation to the search model