1 | <?php |
||
51 | class ElasticSearchPlatform implements IFullTextSearchPlatform { |
||
52 | |||
53 | /** @var ConfigService */ |
||
54 | private $configService; |
||
55 | |||
56 | /** @var IndexService */ |
||
57 | private $indexService; |
||
58 | |||
59 | /** @var SearchService */ |
||
60 | private $searchService; |
||
61 | |||
62 | /** @var MiscService */ |
||
63 | private $miscService; |
||
64 | |||
65 | /** @var Client */ |
||
66 | private $client; |
||
67 | |||
68 | /** @var Runner */ |
||
69 | private $runner; |
||
70 | |||
71 | |||
72 | /** |
||
73 | * return a unique Id of the platform. |
||
74 | */ |
||
75 | public function getId() { |
||
78 | |||
79 | /** |
||
80 | * return a unique Id of the platform. |
||
81 | */ |
||
82 | public function getName() { |
||
85 | |||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getVersion() { |
||
93 | |||
94 | |||
95 | /** |
||
96 | * @return array |
||
|
|||
97 | * @throws ConfigurationException |
||
98 | */ |
||
99 | public function getConfiguration() { |
||
121 | |||
122 | |||
123 | /** |
||
124 | * @param Runner $runner |
||
125 | */ |
||
126 | public function setRunner(Runner $runner) { |
||
129 | |||
130 | /** |
||
131 | * @param $action |
||
132 | * @param bool $force |
||
133 | * |
||
134 | * @throws Exception |
||
135 | */ |
||
136 | private function updateRunnerAction($action, $force = false) { |
||
143 | |||
144 | |||
145 | /** |
||
146 | * @param Index $index |
||
147 | * @param string $message |
||
148 | * @param string $exception |
||
149 | * @param int $sev |
||
150 | */ |
||
151 | private function updateNewIndexError($index, $message, $exception, $sev) { |
||
158 | |||
159 | |||
160 | /** |
||
161 | * @param Index $index |
||
162 | * @param string $message |
||
163 | * @param string $status |
||
164 | * @param int $type |
||
165 | */ |
||
166 | private function updateNewIndexResult($index, $message, $status, $type) { |
||
173 | |||
174 | |||
175 | /** |
||
176 | * Called when loading the platform. |
||
177 | * |
||
178 | * Loading some container and connect to ElasticSearch. |
||
179 | * |
||
180 | * @throws ConfigurationException |
||
181 | * @throws QueryException |
||
182 | * @throws Exception |
||
183 | */ |
||
184 | public function loadPlatform() { |
||
199 | |||
200 | |||
201 | /** |
||
202 | * not used yet. |
||
203 | * |
||
204 | * @return bool |
||
205 | */ |
||
206 | public function testPlatform() { |
||
209 | |||
210 | |||
211 | /** |
||
212 | * called before any index |
||
213 | * |
||
214 | * We create a general index. |
||
215 | * |
||
216 | * @throws ConfigurationException |
||
217 | * @throws BadRequest400Exception |
||
218 | */ |
||
219 | public function initializeIndex() { |
||
222 | |||
223 | |||
224 | /** |
||
225 | * resetIndex(); |
||
226 | * |
||
227 | * Called when admin wants to remove an index specific to a $provider. |
||
228 | * $provider can be null, meaning a reset of the whole index. |
||
229 | * |
||
230 | * @param string $providerId |
||
231 | * |
||
232 | * @throws ConfigurationException |
||
233 | */ |
||
234 | public function resetIndex($providerId) { |
||
241 | |||
242 | |||
243 | /** |
||
244 | * @deprecated |
||
245 | * |
||
246 | * @param IFullTextSearchProvider $provider |
||
247 | * @param $documents |
||
248 | */ |
||
249 | public function indexDocuments(IFullTextSearchProvider $provider, $documents) { |
||
252 | |||
253 | |||
254 | /** |
||
255 | * @param IFullTextSearchProvider $provider |
||
256 | * @param IndexDocument $document |
||
257 | * |
||
258 | * @return Index |
||
259 | */ |
||
260 | public function indexDocument(IFullTextSearchProvider $provider, IndexDocument $document) { |
||
304 | |||
305 | |||
306 | /** |
||
307 | * @param IFullTextSearchProvider $provider |
||
308 | * @param IndexDocument $document |
||
309 | * @param Exception $e |
||
310 | * |
||
311 | * @return array |
||
312 | * @throws AccessIsEmptyException |
||
313 | * @throws ConfigurationException |
||
314 | * @throws \Exception |
||
315 | */ |
||
316 | private function indexDocumentError( |
||
330 | |||
331 | |||
332 | /** |
||
333 | * @param IndexDocument $document |
||
334 | * @param Exception $e |
||
335 | */ |
||
336 | private function manageIndexErrorException(IndexDocument $document, Exception $e) { |
||
345 | |||
346 | |||
347 | /** |
||
348 | * @param Exception $e |
||
349 | * |
||
350 | * @return string |
||
351 | */ |
||
352 | private function parseIndexErrorException(Exception $e) { |
||
365 | |||
366 | |||
367 | /** |
||
368 | * {@inheritdoc} |
||
369 | * @throws ConfigurationException |
||
370 | */ |
||
371 | public function deleteIndexes($indexes) { |
||
378 | |||
379 | |||
380 | /** |
||
381 | * {@inheritdoc} |
||
382 | * @throws ConfigurationException |
||
383 | * @throws Exception |
||
384 | */ |
||
385 | public function searchDocuments( |
||
391 | |||
392 | |||
393 | |||
394 | /** |
||
395 | * {@inheritdoc} |
||
396 | * @throws Exception |
||
397 | */ |
||
398 | public function searchRequest(SearchResult $result, DocumentAccess $access) { |
||
401 | |||
402 | |||
403 | /** |
||
404 | * @param string $providerId |
||
405 | * @param string $documentId |
||
406 | * |
||
407 | * @return IndexDocument |
||
408 | * @throws ConfigurationException |
||
409 | */ |
||
410 | public function getDocument($providerId, $documentId) { |
||
413 | |||
414 | |||
415 | /** |
||
416 | * @param array $hosts |
||
417 | * |
||
418 | * @throws Exception |
||
419 | */ |
||
420 | private function connectToElastic($hosts) { |
||
441 | |||
442 | |||
443 | } |
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.