1 | <?php |
||
58 | class ElasticSearchPlatform implements IFullTextSearchPlatform { |
||
59 | |||
60 | |||
61 | use TPathTools; |
||
|
|||
62 | |||
63 | |||
64 | /** @var ConfigService */ |
||
65 | private $configService; |
||
66 | |||
67 | /** @var IndexService */ |
||
68 | private $indexService; |
||
69 | |||
70 | /** @var SearchService */ |
||
71 | private $searchService; |
||
72 | |||
73 | /** @var MiscService */ |
||
74 | private $miscService; |
||
75 | |||
76 | /** @var Client */ |
||
77 | private $client; |
||
78 | |||
79 | /** @var IRunner */ |
||
80 | private $runner; |
||
81 | |||
82 | |||
83 | /** |
||
84 | * ElasticSearchPlatform constructor. |
||
85 | * |
||
86 | * @param ConfigService $configService |
||
87 | * @param IndexService $indexService |
||
88 | * @param SearchService $searchService |
||
89 | * @param MiscService $miscService |
||
90 | */ |
||
91 | public function __construct( |
||
100 | |||
101 | |||
102 | /** |
||
103 | * return a unique Id of the platform. |
||
104 | */ |
||
105 | public function getId(): string { |
||
108 | |||
109 | |||
110 | /** |
||
111 | * return a unique Id of the platform. |
||
112 | */ |
||
113 | public function getName(): string { |
||
116 | |||
117 | |||
118 | /** |
||
119 | * @return array |
||
120 | * @throws ConfigurationException |
||
121 | */ |
||
122 | public function getConfiguration(): array { |
||
143 | |||
144 | |||
145 | /** |
||
146 | * @param IRunner $runner |
||
147 | */ |
||
148 | public function setRunner(IRunner $runner) { |
||
151 | |||
152 | |||
153 | /** |
||
154 | * Called when loading the platform. |
||
155 | * |
||
156 | * Loading some container and connect to ElasticSearch. |
||
157 | * |
||
158 | * @throws ConfigurationException |
||
159 | * @throws Exception |
||
160 | */ |
||
161 | public function loadPlatform() { |
||
168 | |||
169 | |||
170 | /** |
||
171 | * not used yet. |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function testPlatform(): bool { |
||
178 | |||
179 | |||
180 | /** |
||
181 | * called before any index |
||
182 | * |
||
183 | * We create a general index. |
||
184 | * |
||
185 | * @throws ConfigurationException |
||
186 | * @throws BadRequest400Exception |
||
187 | */ |
||
188 | public function initializeIndex() { |
||
191 | |||
192 | |||
193 | /** |
||
194 | * resetIndex(); |
||
195 | * |
||
196 | * Called when admin wants to remove an index specific to a $provider. |
||
197 | * $provider can be null, meaning a reset of the whole index. |
||
198 | * |
||
199 | * @param string $providerId |
||
200 | * |
||
201 | * @throws ConfigurationException |
||
202 | */ |
||
203 | public function resetIndex(string $providerId) { |
||
210 | |||
211 | |||
212 | /** |
||
213 | * @param IIndexDocument $document |
||
214 | * |
||
215 | * @return IIndex |
||
216 | */ |
||
217 | public function indexDocument(IIndexDocument $document): IIndex { |
||
260 | |||
261 | |||
262 | /** |
||
263 | * @param IIndexDocument $document |
||
264 | * @param Exception $e |
||
265 | * |
||
266 | * @return array |
||
267 | * @throws AccessIsEmptyException |
||
268 | * @throws ConfigurationException |
||
269 | * @throws Exception |
||
270 | */ |
||
271 | private function indexDocumentError(IIndexDocument $document, Exception $e): array { |
||
281 | |||
282 | |||
283 | /** |
||
284 | * @param IIndexDocument $document |
||
285 | * @param Exception $e |
||
286 | */ |
||
287 | private function manageIndexErrorException(IIndexDocument $document, Exception $e) { |
||
296 | |||
297 | |||
298 | /** |
||
299 | * @param Exception $e |
||
300 | * |
||
301 | * @return string |
||
302 | */ |
||
303 | private function parseIndexErrorException(Exception $e): string { |
||
316 | |||
317 | |||
318 | /** |
||
319 | * {@inheritdoc} |
||
320 | * @throws ConfigurationException |
||
321 | */ |
||
322 | public function deleteIndexes(array $indexes) { |
||
329 | |||
330 | |||
331 | /** |
||
332 | * {@inheritdoc} |
||
333 | * @throws Exception |
||
334 | */ |
||
335 | public function searchRequest(ISearchResult $result, IDocumentAccess $access) { |
||
338 | |||
339 | |||
340 | /** |
||
341 | * @param string $providerId |
||
342 | * @param string $documentId |
||
343 | * |
||
344 | * @return IIndexDocument |
||
345 | * @throws ConfigurationException |
||
346 | */ |
||
347 | public function getDocument(string $providerId, string $documentId): IIndexDocument { |
||
350 | |||
351 | |||
352 | private function cleanHost($host) { |
||
355 | |||
356 | /** |
||
357 | * @param array $hosts |
||
358 | * |
||
359 | * @throws Exception |
||
360 | */ |
||
361 | private function connectToElastic(array $hosts) { |
||
382 | |||
383 | |||
384 | /** |
||
385 | * @param string $action |
||
386 | * @param bool $force |
||
387 | * |
||
388 | * @throws Exception |
||
389 | */ |
||
390 | private function updateRunnerAction(string $action, bool $force = false) { |
||
397 | |||
398 | |||
399 | /** |
||
400 | * @param IIndex $index |
||
401 | * @param string $message |
||
402 | * @param string $exception |
||
403 | * @param int $sev |
||
404 | */ |
||
405 | private function updateNewIndexError(IIndex $index, string $message, string $exception, int $sev |
||
413 | |||
414 | |||
415 | /** |
||
416 | * @param IIndex $index |
||
417 | * @param string $message |
||
418 | * @param string $status |
||
419 | * @param int $type |
||
420 | */ |
||
421 | private function updateNewIndexResult(IIndex $index, string $message, string $status, int $type |
||
429 | |||
430 | |||
431 | } |
||
432 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.