query to query_factory