Client.php in Search API Elasticsearch 8
File
src/Elastica/Client.php
View source
<?php
namespace Drupal\search_api_elasticsearch\Elastica;
use Elastica\Client as ElasticaClient;
use Elastica\Request;
use Drupal\search_api_elasticsearch\Logger\RequestLogger;
class Client extends ElasticaClient {
public function request($path, $method = Request::GET, $data = array(), array $query = array()) {
$response = parent::request($path, $method, $data, $query);
$this
->logQuery($path, $method, $data, $query);
return $response;
}
private function logQuery($path, $method, $data, array $query) {
if (!$this->_logger || !$this->_logger instanceof RequestLogger) {
return;
}
$connection = $this
->getLastRequest()
->getConnection();
$connection_info = array(
'host' => $connection
->getHost(),
'port' => $connection
->getPort(),
'transport' => $connection
->getTransport(),
'headers' => $connection
->hasConfig('headers') ? $connection
->getConfig('headers') : array(),
);
$this->_logger
->logQuery($path, $method, $data, $connection_info, $query);
}
}
Classes
Name |
Description |
Client |
Class Client
@package Drupal\search_api_elasticsearch\Elastica |