filter

jetpack_instant_search_options

Customize Instant Search Options.

Parameters

$options
array

Array of parameters used in Instant Search queries.

Changelog

How to use this hook

See “How to use actions and filters to customize Jetpack”.

Notes

You can use this filter to customize all search queries used in Jetpack’s Search. In the example below, we will filter all search queries so that only results from products and pages are shown. This does not impact the number of records that are indexed though.
function jp_filter_query( $options ) {
    $options['adminQueryFilter'] = array(
        'bool' => array(
            'should' => array(
                array( 'term' => array( 'post_type' => product' ) ),
                array( 'term' => array( 'post_type' => page ) ),
            )
        )
    );
    return $options;
}
add_filter( 'jetpack_instant_search_options', 'jp_filter_query' );
One could also use that filter to remove all posts/pages with a certain category, like so:
function jp_filter_query( $options ) {
    $options['adminQueryFilter'] = array(
        'bool' => array(
            'must_not' => array(
                array( 'term' => array( category.slug' => 'removeme' ) ),
            )
        )
    );
    return $options;
}
add_filter( 'jetpack_instant_search_options', 'jp_filter_query' );
You can check our ElasticSearch documentation to find out more about the other fields you could use to customize queries.