Query match engine