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 | /** |
||
148 | * @param Index $index |
||
149 | * @param string $message |
||
150 | * @param string $exception |
||
151 | * @param int $sev |
||
152 | */ |
||
153 | private function updateNewIndexError($index, $message, $exception, $sev) { |
||
160 | |||
161 | |||
162 | /** |
||
163 | * @param Index $index |
||
164 | * @param string $message |
||
165 | * @param string $status |
||
166 | * @param int $type |
||
167 | */ |
||
168 | private function updateNewIndexResult($index, $message, $status, $type) { |
||
175 | |||
176 | |||
177 | /** |
||
178 | * Called when loading the platform. |
||
179 | * |
||
180 | * Loading some container and connect to ElasticSearch. |
||
181 | * |
||
182 | * @throws ConfigurationException |
||
183 | * @throws QueryException |
||
184 | * @throws Exception |
||
185 | */ |
||
186 | public function loadPlatform() { |
||
201 | |||
202 | |||
203 | /** |
||
204 | * not used yet. |
||
205 | * |
||
206 | * @return bool |
||
207 | */ |
||
208 | public function testPlatform() { |
||
211 | |||
212 | |||
213 | /** |
||
214 | * called before any index |
||
215 | * |
||
216 | * We create a general index. |
||
217 | * |
||
218 | * @throws ConfigurationException |
||
219 | * @throws BadRequest400Exception |
||
220 | */ |
||
221 | public function initializeIndex() { |
||
224 | |||
225 | |||
226 | /** |
||
227 | * resetIndex(); |
||
228 | * |
||
229 | * Called when admin wants to remove an index specific to a $provider. |
||
230 | * $provider can be null, meaning a reset of the whole index. |
||
231 | * |
||
232 | * @param string $providerId |
||
233 | * |
||
234 | * @throws ConfigurationException |
||
235 | */ |
||
236 | public function resetIndex($providerId) { |
||
243 | |||
244 | |||
245 | /** |
||
246 | * @deprecated |
||
247 | * |
||
248 | * @param IFullTextSearchProvider $provider |
||
249 | * @param $documents |
||
250 | */ |
||
251 | public function indexDocuments(IFullTextSearchProvider $provider, $documents) { |
||
254 | |||
255 | |||
256 | /** |
||
257 | * @param IFullTextSearchProvider $provider |
||
258 | * @param IndexDocument $document |
||
259 | * |
||
260 | * @return Index |
||
261 | * @throws AccessIsEmptyException |
||
262 | * @throws ConfigurationException |
||
263 | * @throws InterruptException |
||
264 | * @throws TickDoesNotExistException |
||
265 | */ |
||
266 | public function indexDocument(IFullTextSearchProvider $provider, IndexDocument $document) { |
||
310 | |||
311 | |||
312 | /** |
||
313 | * @param IFullTextSearchProvider $provider |
||
314 | * @param IndexDocument $document |
||
315 | * @param Exception $e |
||
316 | * |
||
317 | * @return array |
||
318 | * @throws AccessIsEmptyException |
||
319 | * @throws ConfigurationException |
||
320 | * @throws InterruptException |
||
321 | * @throws TickDoesNotExistException |
||
322 | */ |
||
323 | private function indexDocumentError( |
||
337 | |||
338 | |||
339 | /** |
||
340 | * @param IndexDocument $document |
||
341 | * @param Exception $e |
||
342 | */ |
||
343 | private function manageIndexErrorException(IndexDocument $document, Exception $e) { |
||
352 | |||
353 | |||
354 | /** |
||
355 | * @param Exception $e |
||
356 | * |
||
357 | * @return string |
||
358 | */ |
||
359 | private function parseIndexErrorException(Exception $e) { |
||
372 | |||
373 | |||
374 | /** |
||
375 | * {@inheritdoc} |
||
376 | * @throws ConfigurationException |
||
377 | */ |
||
378 | public function deleteIndexes($indexes) { |
||
385 | |||
386 | |||
387 | /** |
||
388 | * {@inheritdoc} |
||
389 | * @throws ConfigurationException |
||
390 | * @throws Exception |
||
391 | */ |
||
392 | public function searchDocuments( |
||
397 | |||
398 | |||
399 | /** |
||
400 | * @param string $providerId |
||
401 | * @param string $documentId |
||
402 | * |
||
403 | * @return IndexDocument |
||
404 | * @throws ConfigurationException |
||
405 | */ |
||
406 | public function getDocument($providerId, $documentId) { |
||
409 | |||
410 | |||
411 | /** |
||
412 | * @param array $hosts |
||
413 | * |
||
414 | * @throws Exception |
||
415 | */ |
||
416 | private function connectToElastic($hosts) { |
||
437 | |||
438 | |||
439 | } |
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.