Skip to content

Commit defd5b3

Browse files
algolia-botmillotp
andcommitted
feat(clients): add optionnal scopes to replaceAllObjects [skip-bc] (generated)
algolia/api-clients-automation#4296 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 9dabb5b commit defd5b3

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

algoliasearch/src/main/java/com/algolia/api/SearchClient.java

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6835,7 +6835,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterabl
68356835
* @throws AlgoliaRuntimeException When an error occurred during the serialization
68366836
*/
68376837
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);
68396839
}
68406840

68416841
/**
@@ -6848,6 +6848,28 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterabl
68486848
* @param objects The array of `objects` to store in the given Algolia `indexName`.
68496849
* @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
68506850
* 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'].
68516873
* @param requestOptions The requestOptions to send along with the query, they will be merged with
68526874
* the transporter requestOptions. (optional)
68536875
* @throws AlgoliaRetryException When the retry has failed on all hosts
@@ -6858,6 +6880,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
68586880
String indexName,
68596881
Iterable<T> objects,
68606882
int batchSize,
6883+
List<ScopeType> scopes,
68616884
RequestOptions requestOptions
68626885
) {
68636886
Random rnd = new Random();
@@ -6867,16 +6890,21 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
68676890
batchSize = 1000;
68686891
}
68696892

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+
68706903
try {
68716904
// Copy settings, synonyms and rules
68726905
UpdatedAtResponse copyOperationResponse = operationIndex(
68736906
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),
68806908
requestOptions
68816909
);
68826910

@@ -6887,12 +6915,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
68876915

68886916
copyOperationResponse = operationIndex(
68896917
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),
68966919
requestOptions
68976920
);
68986921
waitForTask(tmpIndexName, copyOperationResponse.getTaskID(), requestOptions);

0 commit comments

Comments
 (0)