Test query matching