def METHOD_NAME(env):
    env = Env(moduleArgs = 'DEFAULT_DIALECT 2')
    conn = getConnectionByEnv(env)
    env.flush()
    env.expect('FT.CREATE', 'idx', 'PREFIX', 1, 'dkey', 'SCHEMA', 'name', 'TEXT', 'breed', 'TEXT', 'loc', 'GEO').ok()
    waitForIndex(env, 'idx')
    conn.execute_command('HSET', 'dkey:1', 'name', 'Lassie', 'breed', 'Rough Collie')
    conn.execute_command('HSET', 'dkey:2', 'name', 'lessly', 'breed', 'Poodle')
    conn.execute_command('HSET', 'dkey:3', 'name', 'Perrito', 'breed', 'poodle')
    conn.execute_command('HSET', 'dkey:4', 'name', 'Lou Dog', 'breed', 'Dalmatian')
    conn.execute_command('HSET', 'dkey:5', 'name', 'dipper', 'breed', 'dalmatian')
    conn.execute_command('HSET', 'dkey:6', 'name', 'Duff', 'breed', 'Dalmatian')
    conn.execute_command('HSET', 'dkey:7', 'name', 'Triumph', 'breed', 'Mountain Hound')
    conn.execute_command('HSET', 'dkey:8', 'name', 'Chuck', 'breed', 'Saluki')
    conn.execute_command('HSET', 'dkey:9', 'name', 'Tuk', 'breed', 'Husky')
    conn.execute_command('HSET', 'dkey:10', 'name', 'Jul', 'breed', 'St. Bernard')
    res1 = env.execute_command('ft.aggregate', 'idx', '@breed:(Dal*|Poo*|Ru*|Mo*)', 'LOAD', '2', '@name', '@breed', 'FILTER', 'exists(@breed)', 'APPLY', 'upper(@name)', 'AS', 'n', 'APPLY', 'upper(@breed)', 'AS', 'b', 'SORTBY', '4', '@b', 'ASC', '@n', 'ASC')
    res2 = env.execute_command('ft.aggregate', 'idx', '@breed:($p1*|$p2*|$p3*|$p4*)', 'LOAD', '2', '@name', '@breed', 'FILTER', 'exists(@breed)', 'APPLY', 'upper(@name)', 'AS', 'n', 'APPLY', 'upper(@breed)', 'AS', 'b', 'SORTBY', '4', '@b', 'ASC', '@n', 'ASC', 'PARAMS', '8', 'p1', 'Dal', 'p2', 'Poo', 'p3', 'Ru', 'p4', 'Mo')
    env.assertEqual(res2, res1)
    res1 = env.execute_command('ft.aggregate', 'idx', '@breed:(Dal*|Poo*|Ru*|Mo*)', 'SORTBY', '1', '@name')
    res2 = env.execute_command('ft.aggregate', 'idx', '@breed:($p1*|$p2*|$p3*|$p4*)', 'PARAMS', '8', 'p1', 'Dal', 'p2', 'Poo', 'p3', 'Ru', 'p4', 'Mo', 'SORTBY', '1', '@name')
    env.assertEqual(res2, res1)