facetwp create custom range facet

<?php

/** custom index to display a facet as a range
 ** change 'CHANGE_ME' to the name of your facet
 ** facet the datasource should be the value
 ** you want to show as a range **/

add_filter( 'facetwp_index_row', function( $params, $class ) {
    if ( 'CHANGE_ME' == $params['facet_name'] ) {  
        $price = $params['facet_value'];
        switch ( true ) {
            case ( $price < 10 ):
                $params['facet_value'] = '10';
                $params['facet_display_value'] = 'Less than $10';
                break;
            case ( $price <= 50 ):
                $params['facet_value'] = '50';
                $params['facet_display_value'] = '$10 to $50';
                break;
            case ( $price > 50 ):
                $params['facet_value'] = '100';
                $params['facet_display_value'] = 'over $50';
                break;   
            default: // no value
                $params['facet_value'] = ''; // skip indexing
        }
	} 
    return $params;
}, 10, 2 );