Query-based matching