Query framework