How to specify execution order of filter and query?