1 | <?php |
||
52 | class ElasticSearchPlatform implements IFullTextSearchPlatform { |
||
53 | |||
54 | /** @var ConfigService */ |
||
55 | private $configService; |
||
56 | |||
57 | /** @var IndexService */ |
||
58 | private $indexService; |
||
59 | |||
60 | /** @var SearchService */ |
||
61 | private $searchService; |
||
62 | |||
63 | /** @var MiscService */ |
||
64 | private $miscService; |
||
65 | |||
66 | /** @var Client */ |
||
67 | private $client; |
||
68 | |||
69 | /** @var Runner */ |
||
70 | private $runner; |
||
71 | |||
72 | |||
73 | /** |
||
74 | * return a unique Id of the platform. |
||
75 | */ |
||
76 | public function getId() { |
||
79 | |||
80 | /** |
||
81 | * return a unique Id of the platform. |
||
82 | */ |
||
83 | public function getName() { |
||
86 | |||
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | public function getVersion() { |
||
94 | |||
95 | |||
96 | /** |
||
97 | * @return array |
||
|
|||
98 | * @throws ConfigurationException |
||
99 | */ |
||
100 | public function getConfiguration() { |
||
122 | |||
123 | |||
124 | /** |
||
125 | * @param Runner $runner |
||
126 | */ |
||
127 | public function setRunner(Runner $runner) { |
||
130 | |||
131 | /** |
||
132 | * @param $action |
||
133 | * @param bool $force |
||
134 | * |
||
135 | * @throws InterruptException |
||
136 | * @throws TickDoesNotExistException |
||
137 | */ |
||
138 | private function updateRunnerAction($action, $force = false) { |
||
145 | |||
146 | /** |
||
147 | * @param string $info |
||
148 | * @param string $value |
||
149 | * @param string $color |
||
150 | */ |
||
151 | private function updateRunnerInfo($info, $value, $color = '') { |
||
158 | |||
159 | /** |
||
160 | * @param array $data |
||
161 | */ |
||
162 | private function updateRunnerInfoArray($data) { |
||
169 | |||
170 | |||
171 | /** |
||
172 | * @param Index $index |
||
173 | * @param string $message |
||
174 | * @param string $exception |
||
175 | * @param int $sev |
||
176 | */ |
||
177 | private function updateNewIndexError($index, $message, $exception, $sev) { |
||
184 | |||
185 | |||
186 | /** |
||
187 | * Called when loading the platform. |
||
188 | * |
||
189 | * Loading some container and connect to ElasticSearch. |
||
190 | * |
||
191 | * @throws ConfigurationException |
||
192 | * @throws QueryException |
||
193 | * @throws Exception |
||
194 | */ |
||
195 | public function loadPlatform() { |
||
210 | |||
211 | |||
212 | /** |
||
213 | * not used yet. |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function testPlatform() { |
||
218 | return $this->client->ping(); |
||
219 | } |
||
220 | |||
221 | |||
222 | /** |
||
223 | * called before any index |
||
224 | * |
||
225 | * We create a general index. |
||
226 | * |
||
227 | * @throws ConfigurationException |
||
228 | * @throws BadRequest400Exception |
||
229 | */ |
||
230 | public function initializeIndex() { |
||
231 | $this->indexService->initializeIndex($this->client); |
||
232 | } |
||
233 | |||
234 | |||
235 | /** |
||
236 | * resetIndex(); |
||
237 | * |
||
238 | * Called when admin wants to remove an index specific to a $provider. |
||
239 | * $provider can be null, meaning a reset of the whole index. |
||
240 | * |
||
241 | * @param string $providerId |
||
242 | * |
||
243 | * @throws ConfigurationException |
||
244 | */ |
||
245 | public function resetIndex($providerId) { |
||
246 | if ($providerId === 'all') { |
||
247 | $this->indexService->resetIndexAll($this->client); |
||
248 | } else { |
||
249 | $this->indexService->resetIndex($this->client, $providerId); |
||
250 | } |
||
251 | } |
||
252 | |||
253 | |||
254 | /** |
||
255 | * @deprecated |
||
256 | * |
||
257 | * @param IFullTextSearchProvider $provider |
||
258 | * @param $documents |
||
259 | */ |
||
260 | public function indexDocuments(IFullTextSearchProvider $provider, $documents) { |
||
263 | |||
264 | |||
265 | /** |
||
266 | * @param IFullTextSearchProvider $provider |
||
267 | * @param IndexDocument $document |
||
268 | * |
||
269 | * @return Index |
||
270 | * @throws AccessIsEmptyException |
||
271 | * @throws ConfigurationException |
||
272 | * @throws InterruptException |
||
273 | * @throws TickDoesNotExistException |
||
274 | */ |
||
275 | public function indexDocument(IFullTextSearchProvider $provider, IndexDocument $document) { |
||
306 | |||
307 | |||
308 | /** |
||
309 | * @param IFullTextSearchProvider $provider |
||
310 | * @param IndexDocument $document |
||
311 | * @param Exception $e |
||
312 | * |
||
313 | * @return Index |
||
314 | * @throws AccessIsEmptyException |
||
315 | * @throws ConfigurationException |
||
316 | * @throws InterruptException |
||
317 | * @throws TickDoesNotExistException |
||
318 | */ |
||
319 | private function indexDocumentError( |
||
335 | |||
336 | |||
337 | /** |
||
338 | * @param IndexDocument $document |
||
339 | * @param Exception $e |
||
340 | */ |
||
341 | private function manageIndexErrorException(IndexDocument $document, Exception $e) { |
||
350 | |||
351 | |||
352 | /** |
||
353 | * @param Exception $e |
||
354 | * |
||
355 | * @return string |
||
356 | */ |
||
357 | private function parseIndexErrorException(Exception $e) { |
||
370 | |||
371 | |||
372 | /** |
||
373 | * {@inheritdoc} |
||
374 | * @throws ConfigurationException |
||
375 | */ |
||
376 | public function deleteIndexes($indexes) { |
||
383 | |||
384 | |||
385 | /** |
||
386 | * {@inheritdoc} |
||
387 | * @throws ConfigurationException |
||
388 | * @throws Exception |
||
389 | */ |
||
390 | public function searchDocuments( |
||
395 | |||
396 | |||
397 | /** |
||
398 | * @param string $providerId |
||
399 | * @param string $documentId |
||
400 | * |
||
401 | * @return IndexDocument |
||
402 | * @throws ConfigurationException |
||
403 | */ |
||
404 | public function getDocument($providerId, $documentId) { |
||
407 | |||
408 | |||
409 | /** |
||
410 | * @param array $hosts |
||
411 | * |
||
412 | * @throws Exception |
||
413 | */ |
||
414 | private function connectToElastic($hosts) { |
||
435 | |||
436 | |||
437 | } |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.