@@ -2896,48 +2896,54 @@ public function replaceAllObjects($indexName, $objects, $batchSize = 1000, $requ
28962896 {
28972897 $ tmpIndexName = $ indexName .'_tmp_ ' .rand (10000000 , 99999999 );
28982898
2899- $ copyOperationResponse = $ this ->operationIndex (
2900- $ indexName ,
2901- [
2902- 'operation ' => 'copy ' ,
2903- 'destination ' => $ tmpIndexName ,
2904- 'scope ' => ['settings ' , 'rules ' , 'synonyms ' ],
2905- ],
2906- $ requestOptions
2907- );
2899+ try {
2900+ $ copyOperationResponse = $ this ->operationIndex (
2901+ $ indexName ,
2902+ [
2903+ 'operation ' => 'copy ' ,
2904+ 'destination ' => $ tmpIndexName ,
2905+ 'scope ' => ['settings ' , 'rules ' , 'synonyms ' ],
2906+ ],
2907+ $ requestOptions
2908+ );
29082909
2909- $ batchResponses = $ this ->chunkedBatch ($ tmpIndexName , $ objects , 'addObject ' , true , $ batchSize , $ requestOptions );
2910+ $ batchResponses = $ this ->chunkedBatch ($ tmpIndexName , $ objects , 'addObject ' , true , $ batchSize , $ requestOptions );
29102911
2911- $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
2912+ $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
29122913
2913- $ copyOperationResponse = $ this ->operationIndex (
2914- $ indexName ,
2915- [
2916- 'operation ' => 'copy ' ,
2917- 'destination ' => $ tmpIndexName ,
2918- 'scope ' => ['settings ' , 'rules ' , 'synonyms ' ],
2919- ],
2920- $ requestOptions
2921- );
2914+ $ copyOperationResponse = $ this ->operationIndex (
2915+ $ indexName ,
2916+ [
2917+ 'operation ' => 'copy ' ,
2918+ 'destination ' => $ tmpIndexName ,
2919+ 'scope ' => ['settings ' , 'rules ' , 'synonyms ' ],
2920+ ],
2921+ $ requestOptions
2922+ );
29222923
2923- $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
2924+ $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
29242925
2925- $ moveOperationResponse = $ this ->operationIndex (
2926- $ tmpIndexName ,
2927- [
2928- 'operation ' => 'move ' ,
2929- 'destination ' => $ indexName ,
2930- ],
2931- $ requestOptions
2932- );
2926+ $ moveOperationResponse = $ this ->operationIndex (
2927+ $ tmpIndexName ,
2928+ [
2929+ 'operation ' => 'move ' ,
2930+ 'destination ' => $ indexName ,
2931+ ],
2932+ $ requestOptions
2933+ );
29332934
2934- $ this ->waitForTask ($ tmpIndexName , $ moveOperationResponse ['taskID ' ]);
2935+ $ this ->waitForTask ($ tmpIndexName , $ moveOperationResponse ['taskID ' ]);
29352936
2936- return [
2937- 'copyOperationResponse ' => $ copyOperationResponse ,
2938- 'batchResponses ' => $ batchResponses ,
2939- 'moveOperationResponse ' => $ moveOperationResponse ,
2940- ];
2937+ return [
2938+ 'copyOperationResponse ' => $ copyOperationResponse ,
2939+ 'batchResponses ' => $ batchResponses ,
2940+ 'moveOperationResponse ' => $ moveOperationResponse ,
2941+ ];
2942+ } catch (\Throwable $ e ) {
2943+ $ this ->deleteIndex ($ tmpIndexName );
2944+
2945+ throw $ e ;
2946+ }
29412947 }
29422948
29432949 /**
@@ -3092,7 +3098,7 @@ public function indexExists($indexName)
30923098 $ this ->getSettings ($ indexName );
30933099 } catch (NotFoundException $ e ) {
30943100 return false ;
3095- } catch (Exception $ e ) {
3101+ } catch (\ Throwable $ e ) {
30963102 throw $ e ;
30973103 }
30983104
0 commit comments