WordPress at a glance
function is not described

WP_REST_Post_Search_Handler::search_items() WP 5.0.0

Searches the object type content for a given search request.

This is a method of the class: WP_REST_Post_Search_Handler

Hooks from the method
Return

Array. Associative array containing an WP_REST_Search_Handler::RESULT_IDS containing an array of found IDs and WP_REST_Search_Handler::RESULT_TOTAL containing the total count for the matching search results.

Usage

$WP_REST_Post_Search_Handler = new WP_REST_Post_Search_Handler();
$var = $WP_REST_Post_Search_Handler->search_items( $request );
$request(WP_REST_Request) (required)
Full REST request.

Changelog

Since 5.0.0 Introduced.

Code of WP REST Post Search Handler::search items: wp-includes/rest-api/search/class-wp-rest-post-search-handler.php WP 5.2.2

<?php
public function search_items( WP_REST_Request $request ) {

	// Get the post types to search for the current request.
	$post_types = $request[ WP_REST_Search_Controller::PROP_SUBTYPE ];
	if ( in_array( WP_REST_Search_Controller::TYPE_ANY, $post_types, true ) ) {
		$post_types = $this->subtypes;
	}

	$query_args = array(
		'post_type'           => $post_types,
		'post_status'         => 'publish',
		'paged'               => (int) $request['page'],
		'posts_per_page'      => (int) $request['per_page'],
		'ignore_sticky_posts' => true,
		'fields'              => 'ids',
	);

	if ( ! empty( $request['search'] ) ) {
		$query_args['s'] = $request['search'];
	}

	/**
	 * Filters the query arguments for a search request.
	 *
	 * Enables adding extra arguments or setting defaults for a post search request.
	 *
	 * @since 5.1.0
	 *
	 * @param array           $query_args Key value array of query var to query value.
	 * @param WP_REST_Request $request    The request used.
	 */
	$query_args = apply_filters( 'rest_post_search_query', $query_args, $request );

	$query     = new WP_Query();
	$found_ids = $query->query( $query_args );
	$total     = $query->found_posts;

	return array(
		self::RESULT_IDS   => $found_ids,
		self::RESULT_TOTAL => $total,
	);
}