EP_API::get_search_status PHP Method

get_search_status() public method

Retrieves various search statistics from the ES server.
Since: 1.9
public get_search_status ( integer $blog_id = null ) : array
$blog_id integer Id of blog to get stats.
return array Contains the status message or the returned statistics.
    public function get_search_status($blog_id = null)
    {
        if (is_wp_error(ep_get_host())) {
            return array('status' => false, 'msg' => esc_html__('Elasticsearch Host is not available.', 'elasticpress'));
        } else {
            if (is_multisite() && null === $blog_id) {
                $path = ep_get_network_alias() . '/_stats/search/';
            } else {
                $path = ep_get_index_name($blog_id) . '/_stats/search/';
            }
            $request = ep_remote_request($path, array('method' => 'GET'));
        }
        if (!is_wp_error($request)) {
            $stats = json_decode(wp_remote_retrieve_body($request));
            if (isset($stats->_all)) {
                return $stats->_all->primaries->search;
            }
            return false;
        }
        return array('status' => false, 'msg' => $request->get_error_message());
    }