wp query – ElasticPress is (aparently) messing with my search filters

I recently installed ElasticPress on my woocommerce store, and it’s working fine — the product page is showing normally, and the search bar is working fine with the new elastic capabilities. However, when I try to use the product filters, nothing shows up, the query simply doesn’t work. If I deactivate Elasticpress, however, the filters work normally. This is the query:

<?php

defined( 'ABSPATH' ) || exit;

global $wp_query;

add_action( 'woocommerce_product_query', 'tpk_archive_query' );

function tpk_archive_query( $q ){

    if($_GET('js') == 'y') {
        $cat = explode(',', esc_attr($_GET('categorias')));
        $a = explode(',', esc_attr($_GET('artistas')));
        $ta = explode(',', esc_attr($_GET('tamanhos')));
        $c = explode(',', esc_attr($_GET('colecoes')));
        $t = explode(',', esc_attr($_GET('tags')));
        $preco = explode(',', esc_attr($_GET('preco')));
        $operador = strtoupper(esc_attr($_GET('op')));
        $orderby = explode('-', esc_attr($_GET('orderby')));
    } else {
        $cat = esc_attr($_GET('cat'));
        $a = esc_attr($_GET('a'));
        $ta = esc_attr($_GET('ta'));
        $c = esc_attr($_GET('c'));
        $t = esc_attr($_GET('t'));
    }



    if((esc_attr($_GET('orderby')) && !empty(esc_attr($_GET('orderby'))))) {

        if($orderby(0) == 'preco') {

            $q->set('orderby', 'meta_value_num');
            $q->set('meta_key', '_price');
            $q->set('order', $orderby(1));

        } else {

            $q->set('orderby', $orderby(0));
            $q->set('order', $orderby(1));

        }

    }



    $args = (
        'relation' => 'AND',
    );

    if((esc_attr($_GET('cat')) && !empty(esc_attr($_GET('cat'))))) {
        
        $category = (
            'taxonomy' => 'product_cat',
            'field' => 'slug',
            'terms' => $cat,
            'operator' => 'IN'
        );

        array_push($args, $category);
    } elseif(esc_attr($_GET('categorias')) && !empty(esc_attr($_GET('categorias')))) {

        if(in_array('kits', $cat)) {

            $categorias = ('relation' => 'OR',);

            foreach ($cat as $cate) {

                if($cate != 'kits') {

                    $kitCat = 'kits-' . $cate;

                    $cate = ($cate, $kitCat);

                    $pima = (
                        'taxonomy' => 'product_cat',
                        'field' => 'slug',
                        'terms' => $cate,
                        'operator' => 'IN'
                    );
                    
                    array_push($categorias, $pima);

                }

            }

        } else {

            $categorias = (
                'taxonomy' => 'product_cat',
                'field' => 'slug',
                'terms' => $cat,
                'operator' => 'IN'
            );

        }

        array_push($args, $categorias);

    }

    if((esc_attr($_GET('a')) && !empty(esc_attr($_GET('a')))) || (esc_attr($_GET('artistas')) && !empty(esc_attr($_GET('artistas'))))) {
        $artistas = (
            'taxonomy' => 'autor',
            'field' => 'slug',
            'terms' => $a,
            'operator' => 'IN'
        );

        array_push($args, $artistas);
    }

    if((esc_attr($_GET('ta')) && !empty(esc_attr($_GET('ta')))) || (esc_attr($_GET('tamanhos')) && !empty(esc_attr($_GET('tamanhos'))))) {
        $tamanho = (
            'taxonomy' => 'tamanho',
            'field' => 'slug',
            'terms' => $ta,
            'operator' => 'IN'
        );

        array_push($args, $tamanho);
    }

    if((esc_attr($_GET('c')) && !empty(esc_attr($_GET('c')))) || (esc_attr($_GET('colecoes')) && !empty(esc_attr($_GET('colecoes'))))) {
        $colecao = (
            'taxonomy' => 'colecao',
            'field' => 'slug',
            'terms' => $c,
            'operator' => 'IN'
        );

        array_push($args, $colecao);
    }

    if((esc_attr($_GET('t')) && !empty(esc_attr($_GET('t')))) || (esc_attr($_GET('tags')) && !empty(esc_attr($_GET('tags'))))) {
        
        if(!$operador) {
            $operador = 'OR';
        }
        $tags = ('relation' => $operador,);

        foreach ($t as $tag) {
            $poma = (
                'taxonomy' => 'product_tag',
                'field' => 'slug',
                'terms' => $tag,
                'operator' => 'IN'
            );
            
            array_push($tags, $poma);
        }

        array_push($args, $tags);
    }

    $q->set('tax_query', $args);

    if((esc_attr($_GET('preco')) && !empty(esc_attr($_GET('preco'))))) {

        $min_price = $preco(0);
        $max_price = $preco(1);

        $q->set('meta_query', (
            (
                'key' => '_price',
                'value' => ($min_price, $max_price),
                'compare' => 'BETWEEN',
                'type' => 'NUMERIC'
            )
        ));

    }

}

I tried using WP Marvelous Debug to see if there were any errors happening during the query, and it didn’t point at anything different. The only “errors” it pointed out were these undefined indexes, which I don’t belive have anything to do with the problem, because they happen with or without Elastic.

This is the “Query Args” on the ElasticPress debugger:

array(72) {
("orderby")=>
string(28) "meta.total_sales.double date"
("post_type")=>
string(7) "product"
("error")=>
string(0) ""
("m")=>
string(0) ""
("p")=>
int(0)
("post_parent")=>
string(0) ""
("subpost")=>
string(0) ""
("subpost_id")=>
string(0) ""
("attachment")=>
string(0) ""
("attachment_id")=>
int(0)
("name")=>
string(0) ""
("pagename")=>
string(0) ""
("page_id")=>
int(0)
("second")=>
string(0) ""
("minute")=>
string(0) ""
("hour")=>
string(0) ""
("day")=>
int(0)
("monthnum")=>
int(0)
("year")=>
int(0)
("w")=>
int(0)
("category_name")=>
string(0) ""
("tag")=>
string(0) ""
("cat")=>
string(0) ""
("tag_id")=>
string(0) ""
("author")=>
string(0) ""
("author_name")=>
string(0) ""
("feed")=>
string(0) ""
("tb")=>
string(0) ""
("paged")=>
int(0)
("meta_key")=>
string(0) ""
("meta_value")=>
string(0) ""
("preview")=>
string(0) ""
("s")=>
string(0) ""
("sentence")=>
string(0) ""
("title")=>
string(0) ""
("fields")=>
string(0) ""
("menu_order")=>
string(0) ""
("embed")=>
string(0) ""
("category__in")=>
array(0) {
}
("category__not_in")=>
array(0) {
}
("category__and")=>
array(0) {
}
("post__in")=>
array(0) {
}
("post__not_in")=>
array(0) {
}
("post_name__in")=>
array(0) {
}
("tag__in")=>
array(0) {
}
("tag__not_in")=>
array(0) {
}
("tag__and")=>
array(0) {
}
("tag_slug__in")=>
array(0) {
}
("tag_slug__and")=>
array(0) {
}
("post_parent__in")=>
array(0) {
}
("post_parent__not_in")=>
array(0) {
}
("author__in")=>
array(0) {
}
("author__not_in")=>
array(0) {
}
("order")=>
string(4) "DESC"
("meta_query")=>
array(0) {
}
("tax_query")=>
array(2) {
    ("relation")=>
    string(3) "AND"
    (0)=>
    array(4) {
    ("taxonomy")=>
    string(5) "autor"
    ("field")=>
    string(4) "slug"
    ("terms")=>
    array(1) {
        (0)=>
        string(12) "arcane-minis"
    }
    ("operator")=>
    string(2) "IN"
    }
}
("wc_query")=>
string(13) "product_query"
("posts_per_page")=>
int(48)
("ep_integrate")=>
bool(true)
("ep_facet")=>
bool(true)
("aggs")=>
array(3) {
    ("name")=>
    string(5) "terms"
    ("use-filter")=>
    bool(true)
    ("aggs")=>
    array(12) {
    ("category")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(19) "terms.category.slug"
        }
    }
    ("post_tag")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(19) "terms.post_tag.slug"
        }
    }
    ("post_format")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(22) "terms.post_format.slug"
        }
    }
    ("product_cat")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(22) "terms.product_cat.slug"
        }
    }
    ("product_tag")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(22) "terms.product_tag.slug"
        }
    }
    ("product_shipping_class")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(33) "terms.product_shipping_class.slug"
        }
    }
    ("autor")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(16) "terms.autor.slug"
        }
    }
    ("colecao")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(18) "terms.colecao.slug"
        }
    }
    ("tamanho")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(18) "terms.tamanho.slug"
        }
    }
    ("ep_custom_result")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(27) "terms.ep_custom_result.slug"
        }
    }
    ("pa_material")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(22) "terms.pa_material.slug"
        }
    }
    ("pa_variacao")=>
    array(1) {
        ("terms")=>
        array(2) {
        ("size")=>
        int(10000)
        ("field")=>
        string(22) "terms.pa_variacao.slug"
        }
    }
    }
}
("suppress_filters")=>
bool(false)
("ignore_sticky_posts")=>
bool(false)
("cache_results")=>
bool(true)
("update_post_term_cache")=>
bool(true)
("lazy_load_term_meta")=>
bool(true)
("update_post_meta_cache")=>
bool(true)
("nopaging")=>
bool(false)
("comments_per_page")=>
string(2) "30"
("no_found_rows")=>
bool(false)
("taxonomy")=>
string(5) "autor"
("term")=>
string(12) "arcane-minis"
}

Do I have to re-write my queries in an elastic-specific syntax? I spent the last two days trying to fix this and I really have no idea what to do.

Thanks in advance for any help.