diff --git a/templates/go/search_helpers.mustache b/templates/go/search_helpers.mustache index 5de1995c06..7b75162590 100644 --- a/templates/go/search_helpers.mustache +++ b/templates/go/search_helpers.mustache @@ -797,8 +797,8 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act waitForTasks = &defaultWaitForTask } - requests := make([]BatchRequest, 0, len(objects)%1000) - responses := make([]BatchResponse, 0, len(objects)%1000) + requests := make([]BatchRequest, 0, len(objects)%*batchSize) + responses := make([]BatchResponse, 0, len(objects)%*batchSize) for i, obj := range objects { requests = append(requests, *NewBatchRequest(*action, obj)) @@ -810,7 +810,7 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act } responses = append(responses, *resp) - requests = make([]BatchRequest, 0, len(objects)%1000) + requests = make([]BatchRequest, 0, len(objects)%*batchSize) } } diff --git a/templates/java/api_helpers.mustache b/templates/java/api_helpers.mustache index 15f23e8a2d..8efff4536a 100644 --- a/templates/java/api_helpers.mustache +++ b/templates/java/api_helpers.mustache @@ -576,6 +576,18 @@ if (waitForTasks) { return responses; } +public List chunkedBatch(String indexName, Iterable objects, Action action, boolean waitForTasks) { + return chunkedBatch(indexName, objects, action, waitForTasks, 1000, null); +} + +public List chunkedBatch(String indexName, Iterable objects, Action action, boolean waitForTasks, int batchSize) { + return chunkedBatch(indexName, objects, action, waitForTasks, batchSize, null); +} + +public List chunkedBatch(String indexName, Iterable objects, Action action, boolean waitForTasks, RequestOptions requestOptions) { + return chunkedBatch(indexName, objects, action, waitForTasks, 1000, requestOptions); +} + /** * Push a new set of objects and remove all previous ones. Settings, synonyms and query rules are * untouched. Replace all records in an index without any downtime. See