WordPress how to exclude term from indexing

Hi, how can I exclude term from being indexed. In documentation: https://community.algolia.com/wordpress/indexing-flow.html I have examples on how to exclude user, post type and even example on non indexed pages with SEO by yoast but I do not have any example for excluding terms. Documentation clearly states that there is such option: algolia_should_index_term. I have put together this query, but of course that is not working as it is me only guessing. Is there anyone that can help with this. I need to exclude term ‘xclude’ from events CPT - events_category taxonomy. Thanks in advance for help.

function exclude_term( $should_index, WP_Term $term )
// Add all post types you don’t want to make searchable.
$excluded_terms = array( ‘xclude’ );
if ( false === $should_index ) {
return false;

return ! in_array( $term, $excluded_terms, true );


// Hook into Algolia to manipulate the post that should be indexed.
add_filter( ‘algolia_should_index_term’, ‘exclude_term’, 10, 2 );

Can you var_dump($term) and confirm that the function is called with ‘xclude’?