/** * Provide better error messaging for common connection errors * * @since 0.9.3 */ private function _connect_check() { $ep_server_url = ep_get_server_url(); if (!isset($ep_server_url)) { \WP_CLI::error(__('The Elasticsearch server URL is not defined! You should be calling "set-host", at least.', 'elasticpress')); } if (false === ep_elasticsearch_alive()) { \WP_CLI::error(__('Unable to reach Elasticsearch Server! Check that service is running.', 'elasticpress')); } }
/** * Get stats on the current index. * * @return array * @since 0.9.2 */ public function stats($blog_id = null) { $request = wp_remote_get(trailingslashit(ep_get_server_url()) . '_stats/'); if (is_wp_error($request)) { return null; } $body = json_decode(wp_remote_retrieve_body($request), true); $current_index = ep_get_index_name($blog_id); return isset($body['indices'][$current_index]) ? $body['indices'][$current_index] : null; }