1 | <?php |
||
26 | class Client extends BaseClient |
||
27 | { |
||
28 | /** |
||
29 | * Stores created indexes to avoid recreation. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | private $indexCache = []; |
||
34 | |||
35 | /** |
||
36 | * Stores created index template to avoid recreation. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $indexTemplateCache = array(); |
||
41 | |||
42 | /** |
||
43 | * Symfony's debugging Stopwatch. |
||
44 | * |
||
45 | * @var Stopwatch|null |
||
46 | */ |
||
47 | private $stopwatch; |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 13 | public function request($path, $method = Request::GET, $data = [], array $query = [], $contentType = Request::DEFAULT_CONTENT_TYPE) |
|
83 | |||
84 | /** |
||
85 | * @return Index |
||
86 | */ |
||
87 | 13 | public function getIndex(string $name) |
|
88 | { |
||
89 | 13 | if (isset($this->indexCache[$name])) { |
|
90 | 9 | return $this->indexCache[$name]; |
|
91 | } |
||
92 | |||
93 | 13 | return $this->indexCache[$name] = new Index($this, $name); |
|
94 | } |
||
95 | |||
96 | 6 | public function getIndexTemplate($name) |
|
104 | |||
105 | /** |
||
106 | * Sets a stopwatch instance for debugging purposes. |
||
107 | * |
||
108 | * @param Stopwatch $stopwatch |
||
109 | */ |
||
110 | 15 | public function setStopwatch(Stopwatch $stopwatch = null) |
|
114 | |||
115 | /** |
||
116 | * Log the query if we have an instance of ElasticaLogger. |
||
117 | * |
||
118 | * @param string $path |
||
119 | * @param string $method |
||
120 | * @param array|string $data |
||
121 | * @param array $query |
||
122 | * @param int $queryTime |
||
123 | * @param int $engineMS |
||
124 | * @param int $itemCount |
||
125 | */ |
||
126 | 12 | private function logQuery($path, $method, $data, array $query, $queryTime, $engineMS = 0, $itemCount = 0): void |
|
145 | } |
||
146 |