Skip to content

Commit 87bf4ef

Browse files
committed
fix!: saveObjects helper consistency
1 parent 93ca807 commit 87bf4ef

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/extensions/SearchClient.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public suspend fun SearchClient.searchForFacets(
311311
* @param indexName The index in which to perform the request.
312312
* @param objects The list of objects to index.
313313
* @param action The action to perform on the objects. Default is `Action.AddObject`.
314-
* @param waitForTask If true, wait for the task to complete.
314+
* @param waitForTasks If true, wait for the task to complete.
315315
* @param batchSize The size of the batch. Default is 1000.
316316
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
317317
* @return The list of responses from the batch requests.
@@ -321,7 +321,7 @@ public suspend fun SearchClient.chunkedBatch(
321321
indexName: String,
322322
objects: List<JsonObject>,
323323
action: Action = Action.AddObject,
324-
waitForTask: Boolean,
324+
waitForTasks: Boolean,
325325
batchSize: Int = 1000,
326326
requestOptions: RequestOptions? = null,
327327
): List<BatchResponse> {
@@ -340,7 +340,7 @@ public suspend fun SearchClient.chunkedBatch(
340340
)
341341
tasks.add(batch)
342342
}
343-
if (waitForTask) {
343+
if (waitForTasks) {
344344
tasks.forEach { waitForTask(indexName, it.taskID) }
345345
}
346346
return tasks
@@ -351,7 +351,7 @@ public suspend fun SearchClient.chunkedBatch(
351351
*
352352
* @param indexName The index in which to perform the request.
353353
* @param objects The list of objects to index.
354-
* @param waitForTask If true, wait for the task to complete.
354+
* @param waitForTasks If true, wait for the task to complete.
355355
* @param batchSize The size of the batch. Default is 1000.
356356
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
357357
* @return The list of responses from the batch requests.
@@ -360,24 +360,24 @@ public suspend fun SearchClient.chunkedBatch(
360360
public suspend fun SearchClient.saveObjects(
361361
indexName: String,
362362
objects: List<JsonObject>,
363-
waitForTask: Boolean = false,
363+
waitForTasks: Boolean = false,
364364
batchSize: Int = 1000,
365365
requestOptions: RequestOptions? = null,
366366
): List<BatchResponse> = this.chunkedBatch(
367367
indexName = indexName,
368368
objects = objects,
369369
action = Action.AddObject,
370-
waitForTask = waitForTask,
370+
waitForTasks = waitForTasks,
371371
batchSize = batchSize,
372372
requestOptions = requestOptions,
373373
)
374374

375375
/**
376-
* Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
376+
* Helper: Deletes every record for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
377377
*
378378
* @param indexName The index in which to perform the request.
379379
* @param objectIDs The list of objectIDs to delete from the index.
380-
* @param waitForTask If true, wait for the task to complete.
380+
* @param waitForTasks If true, wait for the task to complete.
381381
* @param batchSize The size of the batch. Default is 1000.
382382
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
383383
* @return The list of responses from the batch requests.
@@ -386,14 +386,14 @@ public suspend fun SearchClient.saveObjects(
386386
public suspend fun SearchClient.deleteObjects(
387387
indexName: String,
388388
objectIDs: List<String>,
389-
waitForTask: Boolean = false,
389+
waitForTasks: Boolean = false,
390390
batchSize: Int = 1000,
391391
requestOptions: RequestOptions? = null,
392392
): List<BatchResponse> = this.chunkedBatch(
393393
indexName = indexName,
394394
objects = objectIDs.map { id -> JsonObject(mapOf("objectID" to Json.encodeToJsonElement(id))) },
395395
action = Action.DeleteObject,
396-
waitForTask = waitForTask,
396+
waitForTasks = waitForTasks,
397397
batchSize = batchSize,
398398
requestOptions = requestOptions,
399399
)
@@ -404,7 +404,7 @@ public suspend fun SearchClient.deleteObjects(
404404
* @param indexName The index in which to perform the request.
405405
* @param objects The list of objects to update in the index.
406406
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
407-
* @param waitForTask If true, wait for the task to complete.
407+
* @param waitForTasks If true, wait for the task to complete.
408408
* @param batchSize The size of the batch. Default is 1000.
409409
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
410410
* @return The list of responses from the batch requests.
@@ -414,14 +414,14 @@ public suspend fun SearchClient.partialUpdateObjects(
414414
indexName: String,
415415
objects: List<JsonObject>,
416416
createIfNotExists: Boolean,
417-
waitForTask: Boolean = false,
417+
waitForTasks: Boolean = false,
418418
batchSize: Int = 1000,
419419
requestOptions: RequestOptions? = null,
420420
): List<BatchResponse> = this.chunkedBatch(
421421
indexName = indexName,
422422
objects = objects,
423423
action = if (createIfNotExists) Action.PartialUpdateObject else Action.PartialUpdateObjectNoCreate,
424-
waitForTask = waitForTask,
424+
waitForTasks = waitForTasks,
425425
batchSize = batchSize,
426426
requestOptions = requestOptions,
427427
)
@@ -464,7 +464,7 @@ public suspend fun SearchClient.replaceAllObjects(
464464
indexName = tmpIndexName,
465465
objects = objects,
466466
action = Action.AddObject,
467-
waitForTask = true,
467+
waitForTasks = true,
468468
batchSize = batchSize,
469469
requestOptions = requestOptions,
470470
)

templates/php/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ use Algolia\AlgoliaSearch\Exceptions\NotFoundException;
509509
* @param array $requestOptions Request options
510510
* @param bool $waitForTasks Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable
511511
*/
512-
public function saveObjects($indexName, $objects, $batchSize = 1000, $requestOptions = [], $waitForTasks = false) {
512+
public function saveObjects($indexName, $objects, $waitForTasks = false, $batchSize = 1000, $requestOptions = [])
513513
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, $batchSize, $requestOptions);
514514
}
515515

0 commit comments

Comments
 (0)