Skip to content

Commit

Permalink
feat(clients): allow batch size on objects helper [skip-bc] (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4172

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Nov 29, 2024
1 parent 28ac296 commit 97e019e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public suspend fun SearchClient.chunkedBatch(
* @param indexName The index in which to perform the request.
* @param objects The list of objects to index.
* @param waitForTask If true, wait for the task to complete.
* @param batchSize The size of the batch. Default is 1000.
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
* @return The list of responses from the batch requests.
*
Expand All @@ -379,14 +380,15 @@ public suspend fun SearchClient.saveObjects(
indexName: String,
objects: List<JsonObject>,
waitForTask: Boolean = false,
batchSize: Int = 1000,
requestOptions: RequestOptions? = null,
): List<BatchResponse> {
return this.chunkedBatch(
indexName = indexName,
objects = objects,
action = Action.AddObject,
waitForTask = waitForTask,
batchSize = 1000,
batchSize = batchSize,
requestOptions = requestOptions,
)
}
Expand All @@ -397,6 +399,7 @@ public suspend fun SearchClient.saveObjects(
* @param indexName The index in which to perform the request.
* @param objectIDs The list of objectIDs to delete from the index.
* @param waitForTask If true, wait for the task to complete.
* @param batchSize The size of the batch. Default is 1000.
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
* @return The list of responses from the batch requests.
*
Expand All @@ -405,14 +408,15 @@ public suspend fun SearchClient.deleteObjects(
indexName: String,
objectIDs: List<String>,
waitForTask: Boolean = false,
batchSize: Int = 1000,
requestOptions: RequestOptions? = null,
): List<BatchResponse> {
return this.chunkedBatch(
indexName = indexName,
objects = objectIDs.map { id -> JsonObject(mapOf("objectID" to Json.encodeToJsonElement(id))) },
action = Action.DeleteObject,
waitForTask = waitForTask,
batchSize = 1000,
batchSize = batchSize,
requestOptions = requestOptions,
)
}
Expand All @@ -424,6 +428,7 @@ public suspend fun SearchClient.deleteObjects(
* @param objects The list of objects to update in the index.
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
* @param waitForTask If true, wait for the task to complete.
* @param batchSize The size of the batch. Default is 1000.
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
* @return The list of responses from the batch requests.
*
Expand All @@ -433,14 +438,15 @@ public suspend fun SearchClient.partialUpdateObjects(
objects: List<JsonObject>,
createIfNotExists: Boolean,
waitForTask: Boolean = false,
batchSize: Int = 1000,
requestOptions: RequestOptions? = null,
): List<BatchResponse> {
return this.chunkedBatch(
indexName = indexName,
objects = objects,
action = if (createIfNotExists) Action.PartialUpdateObject else Action.PartialUpdateObjectNoCreate,
waitForTask = waitForTask,
batchSize = 1000,
batchSize = batchSize,
requestOptions = requestOptions,
)
}
Expand Down

0 comments on commit 97e019e

Please sign in to comment.