Block search SQL from happening

It’s possible to avoid SQL execution in WP_Query with the posts_pre_query filter.

It’s e.g. used by plugins to outsource the default search to 3rd party search engines.

Here’s an example how we can override the main search query on the front-end, with an empty posts array and avoid running the SQL search query:

add_filter( 'posts_pre_query', function( $posts, \WP_Query $query ){
    if( $query->is_search() && $query->is_main_query() && ! is_admin() ) {
        return array();
    }
    return $posts;
}, 10, 2 );

Since we’re returning an empty array, I don’t think we need to adjust the
$query->found_posts or $query->max_num_pages as they are zero by default.