Generates filtered query only on exact match else generates a match query