33namespace ColdTrick \OpenSearch \Di ;
44
55use Elgg \Exceptions \UnexpectedValueException ;
6- use OpenSearch \Common \ Exceptions \ OpenSearchException ;
6+ use OpenSearch \Exception \ OpenSearchExceptionInterface ;
77
88/**
99 * Manage the OpenSearch Indexes
@@ -31,7 +31,7 @@ public function getIndexStatus(): ?array {
3131 $ status = $ this ->getClient ()->indices ()->stats ();
3232
3333 return elgg_extract ('indices ' , $ status , false );
34- } catch (OpenSearchException $ e ) {
34+ } catch (OpenSearchExceptionInterface $ e ) {
3535 $ this ->logger ->error ($ e );
3636 }
3737
@@ -50,7 +50,7 @@ public function getClusterInformation(): ?array {
5050
5151 try {
5252 return $ this ->getClient ()->info ();
53- } catch (OpenSearchException $ e ) {
53+ } catch (OpenSearchExceptionInterface $ e ) {
5454 $ this ->logger ->error ($ e );
5555 }
5656
@@ -97,7 +97,7 @@ public function indexExists(string $index): bool {
9797 return $ this ->getClient ()->indices ()->exists ([
9898 'index ' => $ index ,
9999 ]);
100- } catch (OpenSearchException $ e ) {
100+ } catch (OpenSearchExceptionInterface $ e ) {
101101 $ this ->logger ->error ($ e );
102102 }
103103
@@ -122,7 +122,7 @@ public function indexHasAlias(string $index, string $alias): bool {
122122 'index ' => $ index ,
123123 'name ' => $ alias ,
124124 ]);
125- } catch (OpenSearchException $ e ) {
125+ } catch (OpenSearchExceptionInterface $ e ) {
126126 $ this ->logger ->error ($ e );
127127 }
128128
@@ -148,7 +148,7 @@ public function addAlias(string $index, string $alias): bool {
148148 'name ' => $ alias ,
149149 ]);
150150 return (bool ) elgg_extract ('acknowledged ' , $ response , false );
151- } catch (OpenSearchException $ e ) {
151+ } catch (OpenSearchExceptionInterface $ e ) {
152152 $ this ->logger ->error ($ e );
153153 }
154154
@@ -174,7 +174,7 @@ public function getAliases(string $index): ?array {
174174
175175 $ aliases = elgg_extract ('aliases ' , elgg_extract ($ index , $ response , []), []);
176176 return array_keys ($ aliases );
177- } catch (OpenSearchException $ e ) {
177+ } catch (OpenSearchExceptionInterface $ e ) {
178178 $ this ->logger ->error ($ e );
179179 }
180180
@@ -200,7 +200,7 @@ public function deleteAlias(string $index, string $alias): bool {
200200 'name ' => $ alias ,
201201 ]);
202202 return (bool ) elgg_extract ('acknowledged ' , $ response , false );
203- } catch (OpenSearchException $ e ) {
203+ } catch (OpenSearchExceptionInterface $ e ) {
204204 $ this ->logger ->error ($ e );
205205 }
206206
@@ -226,7 +226,7 @@ public function flush(string $index): bool {
226226
227227 $ failed_shards = elgg_extract ('failed ' , elgg_extract ('_shards ' , $ response , []), 0 );
228228 return empty ($ failed_shards );
229- } catch (OpenSearchException $ e ) {
229+ } catch (OpenSearchExceptionInterface $ e ) {
230230 $ this ->logger ->error ($ e );
231231 }
232232
@@ -250,7 +250,7 @@ public function delete(string $index): bool {
250250 'index ' => $ index ,
251251 ]);
252252 return (bool ) elgg_extract ('acknowledged ' , $ response , false );
253- } catch (OpenSearchException $ e ) {
253+ } catch (OpenSearchExceptionInterface $ e ) {
254254 $ this ->logger ->error ($ e );
255255 }
256256
@@ -274,7 +274,7 @@ public function create(string $index): bool {
274274 try {
275275 $ response = $ this ->getClient ()->indices ()->create ($ config );
276276 return (bool ) elgg_extract ('acknowledged ' , $ response , false );
277- } catch (OpenSearchException $ e ) {
277+ } catch (OpenSearchExceptionInterface $ e ) {
278278 $ this ->logger ->error ($ e );
279279 }
280280
@@ -298,7 +298,7 @@ public function addMapping(string $index): bool {
298298 try {
299299 $ response = $ this ->getClient ()->indices ()->putMapping ($ config );
300300 return (bool ) elgg_extract ('acknowledged ' , $ response , false );
301- } catch (OpenSearchException $ e ) {
301+ } catch (OpenSearchExceptionInterface $ e ) {
302302 $ this ->logger ->error ($ e );
303303 }
304304
@@ -330,7 +330,7 @@ public function reindex(string $from_index, string $to_index): ?array {
330330 ],
331331 'wait_for_completion ' => true ,
332332 ]);
333- } catch (OpenSearchException $ e ) {
333+ } catch (OpenSearchExceptionInterface $ e ) {
334334 $ this ->logger ->error ($ e );
335335 }
336336
0 commit comments