relevanssi_site_results

apply_filters( 'relevanssi_site_results', array $results, int $blog_id )

Filters the results Relevanssi finds for a single site in a multisite search.

Parameters

$results
(array) An array of post ID => weight pairs.

$blog_id
(int) The current blog ID.

More information

Along with relevanssi_multi_results, this filter hook serves the same purpose as relevanssi_results does in the single-site search. This filter hook is applied to the results found for a single site (the multisite searching is done one site at a time). The array has post IDs for keys and post weights for the value, so to modify things, adjust the weight.

Later in the process, the results from single sites will be compiled into one array, which is then filtered by relevanssi_multi_results and then sorted descending by the weight.

You can use most relevanssi_results filters directly without any modifications. It’s generally best to modify the weights here instead of the relevanssi_multi_results, as this way you’ll avoid doing lots of switch_to_blog() which slows things down.

For example, to boost the weight of all the users, you can use this:

add_filter( 'relevanssi_site_results', 'rlv_user_weights' );
function rlv_user_weights( $results ) {
    array_walk(
        $results,
        function( &$weight, $post_id ) {
            if ( 'user' === relevanssi_get_post_type( $post_id ) ) {
                $weight *= 2;
            }
        }
    );

	return $results;
}