Use router to generate query