Build the query hash using a query builder