Skip to content

Commit 536a348

Browse files
authored
fix(clients): chunked batch helper size property consistency (#3253)
1 parent 7a0ff1d commit 536a348

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

templates/go/search_helpers.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,8 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act
797797
waitForTasks = &defaultWaitForTask
798798
}
799799

800-
requests := make([]BatchRequest, 0, len(objects)%1000)
801-
responses := make([]BatchResponse, 0, len(objects)%1000)
800+
requests := make([]BatchRequest, 0, len(objects)%*batchSize)
801+
responses := make([]BatchResponse, 0, len(objects)%*batchSize)
802802

803803
for i, obj := range objects {
804804
requests = append(requests, *NewBatchRequest(*action, obj))
@@ -810,7 +810,7 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act
810810
}
811811

812812
responses = append(responses, *resp)
813-
requests = make([]BatchRequest, 0, len(objects)%1000)
813+
requests = make([]BatchRequest, 0, len(objects)%*batchSize)
814814
}
815815
}
816816

templates/java/api_helpers.mustache

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,18 @@ if (waitForTasks) {
576576
return responses;
577577
}
578578
579+
public <T> List<BatchResponse> chunkedBatch(String indexName, Iterable<T> objects, Action action, boolean waitForTasks) {
580+
return chunkedBatch(indexName, objects, action, waitForTasks, 1000, null);
581+
}
582+
583+
public <T> List<BatchResponse> chunkedBatch(String indexName, Iterable<T> objects, Action action, boolean waitForTasks, int batchSize) {
584+
return chunkedBatch(indexName, objects, action, waitForTasks, batchSize, null);
585+
}
586+
587+
public <T> List<BatchResponse> chunkedBatch(String indexName, Iterable<T> objects, Action action, boolean waitForTasks, RequestOptions requestOptions) {
588+
return chunkedBatch(indexName, objects, action, waitForTasks, 1000, requestOptions);
589+
}
590+
579591
/**
580592
* Push a new set of objects and remove all previous ones. Settings, synonyms and query rules are
581593
* untouched. Replace all records in an index without any downtime. See

0 commit comments

Comments
 (0)