Filter the query keys earlier

Signed-off-by: Ian Macalinao <me@ian.pw>