facetwp index only grandchild or deeper terms

<?php

/** indexes only grand child or deeper level terms **/
add_filter( 'facetwp_index_row', function( $params ) {
    if ( 'product_categories' == $params['facet_name'] ) { //change 'product_categories' to name of your facet
		if ( 2 > $params['depth'] ) { // adjust this for different term levels as needed 
			$params['facet_value'] = ''; // skip indexing
		}
	}
	return $params;
});