facetwp convert prices to price ranges

<?php
add_filter( 'facetwp_index_row', function ( $params, $class ) {
    if ( 'my_facet' == $params['facet_name'] ) { // change 'my_facet' to facet name
        if ( $params['facet_value'] > 10000 ) {
            $new_params = $params;
            $new_params['facet_value'] = 50000;
            $new_params['facet_display_value'] = 'Less than 50000';
            $class->insert( $new_params ); // insert each value to the database
            
        }
        if ( $params['facet_value'] > 5000 ) {
            $new_params = $params;
            $new_params['facet_value'] = 10000;
            $new_params['facet_display_value'] = 'Less than 1000';
            $class->insert( $new_params ); // insert each value to the database
            
        }
        /** more checks for additional values **/
        $params['facet_value'] = ''; // skip indexing
    }
           
    return $params;
}, 10, 2 );