FacetWP – index field attached to related post

<?php

add_filter( 'facetwp_index_row', function( $params, $class ) {
    if ( 'public_type' == $params['facet_name'] ) {
        $related_post_id = (int) $params['facet_value'];
        $value = get_field( 'public_type', $related_post_id );
        $params['facet_value'] = $value;
        $params['facet_display_value'] = $value;
    }
    return $params;
}, 10, 2 );