Skip to content

Commit 97e019e

Browse files
feat(clients): allow batch size on objects helper [skip-bc] (generated)
algolia/api-clients-automation#4172 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 28ac296 commit 97e019e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

client/src/commonMain/kotlin/com/algolia/client/extensions/SearchClient.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ public suspend fun SearchClient.chunkedBatch(
371371
* @param indexName The index in which to perform the request.
372372
* @param objects The list of objects to index.
373373
* @param waitForTask If true, wait for the task to complete.
374+
* @param batchSize The size of the batch. Default is 1000.
374375
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
375376
* @return The list of responses from the batch requests.
376377
*
@@ -379,14 +380,15 @@ public suspend fun SearchClient.saveObjects(
379380
indexName: String,
380381
objects: List<JsonObject>,
381382
waitForTask: Boolean = false,
383+
batchSize: Int = 1000,
382384
requestOptions: RequestOptions? = null,
383385
): List<BatchResponse> {
384386
return this.chunkedBatch(
385387
indexName = indexName,
386388
objects = objects,
387389
action = Action.AddObject,
388390
waitForTask = waitForTask,
389-
batchSize = 1000,
391+
batchSize = batchSize,
390392
requestOptions = requestOptions,
391393
)
392394
}
@@ -397,6 +399,7 @@ public suspend fun SearchClient.saveObjects(
397399
* @param indexName The index in which to perform the request.
398400
* @param objectIDs The list of objectIDs to delete from the index.
399401
* @param waitForTask If true, wait for the task to complete.
402+
* @param batchSize The size of the batch. Default is 1000.
400403
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
401404
* @return The list of responses from the batch requests.
402405
*
@@ -405,14 +408,15 @@ public suspend fun SearchClient.deleteObjects(
405408
indexName: String,
406409
objectIDs: List<String>,
407410
waitForTask: Boolean = false,
411+
batchSize: Int = 1000,
408412
requestOptions: RequestOptions? = null,
409413
): List<BatchResponse> {
410414
return this.chunkedBatch(
411415
indexName = indexName,
412416
objects = objectIDs.map { id -> JsonObject(mapOf("objectID" to Json.encodeToJsonElement(id))) },
413417
action = Action.DeleteObject,
414418
waitForTask = waitForTask,
415-
batchSize = 1000,
419+
batchSize = batchSize,
416420
requestOptions = requestOptions,
417421
)
418422
}
@@ -424,6 +428,7 @@ public suspend fun SearchClient.deleteObjects(
424428
* @param objects The list of objects to update in the index.
425429
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
426430
* @param waitForTask If true, wait for the task to complete.
431+
* @param batchSize The size of the batch. Default is 1000.
427432
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
428433
* @return The list of responses from the batch requests.
429434
*
@@ -433,14 +438,15 @@ public suspend fun SearchClient.partialUpdateObjects(
433438
objects: List<JsonObject>,
434439
createIfNotExists: Boolean,
435440
waitForTask: Boolean = false,
441+
batchSize: Int = 1000,
436442
requestOptions: RequestOptions? = null,
437443
): List<BatchResponse> {
438444
return this.chunkedBatch(
439445
indexName = indexName,
440446
objects = objects,
441447
action = if (createIfNotExists) Action.PartialUpdateObject else Action.PartialUpdateObjectNoCreate,
442448
waitForTask = waitForTask,
443-
batchSize = 1000,
449+
batchSize = batchSize,
444450
requestOptions = requestOptions,
445451
)
446452
}

0 commit comments

Comments
 (0)