facetwp index only parent and one level child terms

<?php
/**
 ** only index parent and first level child tax terms
 ** must re-index after adding filter
 **/

add_filter( 'facetwp_index_row', function( $params, $class ) {
    if ( 'my_tax_facet' == $params['facet_name'] && $params['depth'] > 1 ) { // channge 'my_tax_facet' to the facet name being indexed
        $params['facet_value'] = ''; // skip indexing
    }
    return $params;
}, 10, 2 );