@@ -6835,7 +6835,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterabl
6835
6835
* @throws AlgoliaRuntimeException When an error occurred during the serialization
6836
6836
*/
6837
6837
public <T > ReplaceAllObjectsResponse replaceAllObjects (String indexName , Iterable <T > objects , int batchSize ) {
6838
- return replaceAllObjects (indexName , objects , batchSize , null );
6838
+ return replaceAllObjects (indexName , objects , batchSize , null , null );
6839
6839
}
6840
6840
6841
6841
/**
@@ -6848,6 +6848,28 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterabl
6848
6848
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6849
6849
* @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
6850
6850
* to `length(objects) / batchSize`.
6851
+ * @param scopes The `scopes` to keep from the index. Defaults to ['settings', 'rules',
6852
+ * 'synonyms'].
6853
+ * @throws AlgoliaRetryException When the retry has failed on all hosts
6854
+ * @throws AlgoliaApiException When the API sends an http error code
6855
+ * @throws AlgoliaRuntimeException When an error occurred during the serialization
6856
+ */
6857
+ public <T > ReplaceAllObjectsResponse replaceAllObjects (String indexName , Iterable <T > objects , int batchSize , List <ScopeType > scopes ) {
6858
+ return replaceAllObjects (indexName , objects , batchSize , scopes , null );
6859
+ }
6860
+
6861
+ /**
6862
+ * Push a new set of objects and remove all previous ones. Settings, synonyms and query rules are
6863
+ * untouched. Replace all records in an index without any downtime. See
6864
+ * https://api-clients-automation.netlify.app/docs/add-new-api-client#5-helpers for implementation
6865
+ * details.
6866
+ *
6867
+ * @param indexName The `indexName` to replace `objects` in.
6868
+ * @param objects The array of `objects` to store in the given Algolia `indexName`.
6869
+ * @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
6870
+ * to `length(objects) / batchSize`.
6871
+ * @param scopes The `scopes` to keep from the index. Defaults to ['settings', 'rules',
6872
+ * 'synonyms'].
6851
6873
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6852
6874
* the transporter requestOptions. (optional)
6853
6875
* @throws AlgoliaRetryException When the retry has failed on all hosts
@@ -6858,6 +6880,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
6858
6880
String indexName ,
6859
6881
Iterable <T > objects ,
6860
6882
int batchSize ,
6883
+ List <ScopeType > scopes ,
6861
6884
RequestOptions requestOptions
6862
6885
) {
6863
6886
Random rnd = new Random ();
@@ -6867,16 +6890,21 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
6867
6890
batchSize = 1000 ;
6868
6891
}
6869
6892
6893
+ if (scopes == null ) {
6894
+ scopes = new ArrayList <ScopeType >() {
6895
+ {
6896
+ add (ScopeType .SETTINGS );
6897
+ add (ScopeType .RULES );
6898
+ add (ScopeType .SYNONYMS );
6899
+ }
6900
+ };
6901
+ }
6902
+
6870
6903
try {
6871
6904
// Copy settings, synonyms and rules
6872
6905
UpdatedAtResponse copyOperationResponse = operationIndex (
6873
6906
indexName ,
6874
- new OperationIndexParams ()
6875
- .setOperation (OperationType .COPY )
6876
- .setDestination (tmpIndexName )
6877
- .addScope (ScopeType .SETTINGS )
6878
- .addScope (ScopeType .RULES )
6879
- .addScope (ScopeType .SYNONYMS ),
6907
+ new OperationIndexParams ().setOperation (OperationType .COPY ).setDestination (tmpIndexName ).setScope (scopes ),
6880
6908
requestOptions
6881
6909
);
6882
6910
@@ -6887,12 +6915,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
6887
6915
6888
6916
copyOperationResponse = operationIndex (
6889
6917
indexName ,
6890
- new OperationIndexParams ()
6891
- .setOperation (OperationType .COPY )
6892
- .setDestination (tmpIndexName )
6893
- .addScope (ScopeType .SETTINGS )
6894
- .addScope (ScopeType .RULES )
6895
- .addScope (ScopeType .SYNONYMS ),
6918
+ new OperationIndexParams ().setOperation (OperationType .COPY ).setDestination (tmpIndexName ).setScope (scopes ),
6896
6919
requestOptions
6897
6920
);
6898
6921
waitForTask (tmpIndexName , copyOperationResponse .getTaskID (), requestOptions );
0 commit comments