@@ -369,20 +369,22 @@ public suspend fun SearchClient.chunkedBatch(
369369 *
370370 * @param indexName The index in which to perform the request.
371371 * @param objects The list of objects to index.
372+ * @param waitForTask If true, wait for the task to complete.
372373 * @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
373374 * @return The list of responses from the batch requests.
374375 *
375376 */
376377public suspend fun SearchClient.saveObjects (
377378 indexName : String ,
378379 objects : List <JsonObject >,
380+ waitForTask : Boolean = false,
379381 requestOptions : RequestOptions ? = null,
380382): List <BatchResponse > {
381383 return this .chunkedBatch(
382384 indexName = indexName,
383385 objects = objects,
384386 action = Action .AddObject ,
385- waitForTask = false ,
387+ waitForTask = waitForTask ,
386388 batchSize = 1000 ,
387389 requestOptions = requestOptions,
388390 )
@@ -393,20 +395,22 @@ public suspend fun SearchClient.saveObjects(
393395 *
394396 * @param indexName The index in which to perform the request.
395397 * @param objectIDs The list of objectIDs to delete from the index.
398+ * @param waitForTask If true, wait for the task to complete.
396399 * @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
397400 * @return The list of responses from the batch requests.
398401 *
399402 */
400403public suspend fun SearchClient.deleteObjects (
401404 indexName : String ,
402405 objectIDs : List <String >,
406+ waitForTask : Boolean = false,
403407 requestOptions : RequestOptions ? = null,
404408): List <BatchResponse > {
405409 return this .chunkedBatch(
406410 indexName = indexName,
407411 objects = objectIDs.map { id -> JsonObject (mapOf (" objectID" to Json .encodeToJsonElement(id))) },
408412 action = Action .DeleteObject ,
409- waitForTask = false ,
413+ waitForTask = waitForTask ,
410414 batchSize = 1000 ,
411415 requestOptions = requestOptions,
412416 )
@@ -418,6 +422,7 @@ public suspend fun SearchClient.deleteObjects(
418422 * @param indexName The index in which to perform the request.
419423 * @param objects The list of objects to update in the index.
420424 * @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
425+ * @param waitForTask If true, wait for the task to complete.
421426 * @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
422427 * @return The list of responses from the batch requests.
423428 *
@@ -426,13 +431,14 @@ public suspend fun SearchClient.partialUpdateObjects(
426431 indexName : String ,
427432 objects : List <JsonObject >,
428433 createIfNotExists : Boolean ,
434+ waitForTask : Boolean = false,
429435 requestOptions : RequestOptions ? = null,
430436): List <BatchResponse > {
431437 return this .chunkedBatch(
432438 indexName = indexName,
433439 objects = objects,
434440 action = if (createIfNotExists) Action .PartialUpdateObject else Action .PartialUpdateObjectNoCreate ,
435- waitForTask = false ,
441+ waitForTask = waitForTask ,
436442 batchSize = 1000 ,
437443 requestOptions = requestOptions,
438444 )
0 commit comments