@@ -2896,48 +2896,54 @@ public function replaceAllObjects($indexName, $objects, $batchSize = 1000, $requ
2896
2896
{
2897
2897
$ tmpIndexName = $ indexName .'_tmp_ ' .rand (10000000 , 99999999 );
2898
2898
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
+ );
2908
2909
2909
- $ batchResponses = $ this ->chunkedBatch ($ tmpIndexName , $ objects , 'addObject ' , true , $ batchSize , $ requestOptions );
2910
+ $ batchResponses = $ this ->chunkedBatch ($ tmpIndexName , $ objects , 'addObject ' , true , $ batchSize , $ requestOptions );
2910
2911
2911
- $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
2912
+ $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
2912
2913
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
+ );
2922
2923
2923
- $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
2924
+ $ this ->waitForTask ($ tmpIndexName , $ copyOperationResponse ['taskID ' ]);
2924
2925
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
+ );
2933
2934
2934
- $ this ->waitForTask ($ tmpIndexName , $ moveOperationResponse ['taskID ' ]);
2935
+ $ this ->waitForTask ($ tmpIndexName , $ moveOperationResponse ['taskID ' ]);
2935
2936
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
+ }
2941
2947
}
2942
2948
2943
2949
/**
@@ -3092,7 +3098,7 @@ public function indexExists($indexName)
3092
3098
$ this ->getSettings ($ indexName );
3093
3099
} catch (NotFoundException $ e ) {
3094
3100
return false ;
3095
- } catch (Exception $ e ) {
3101
+ } catch (\ Throwable $ e ) {
3096
3102
throw $ e ;
3097
3103
}
3098
3104
0 commit comments