@@ -463,18 +463,20 @@ public extension SearchClient {
463463 /// which creates a `batch` requests with at most 1000 objects in it.
464464 /// - parameter indexName: The name of the index where to save the objects
465465 /// - parameter objects: The new objects
466+ /// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one
466467 /// - parameter requestOptions: The request options
467468 /// - returns: [BatchResponse]
468469 func saveObjects(
469470 indexName: String ,
470471 objects: [ some Encodable ] ,
472+ waitForTasks: Bool ? = false ,
471473 requestOptions: RequestOptions ? = nil
472474 ) async throws -> [ BatchResponse ] {
473475 try await self . chunkedBatch (
474476 indexName: indexName,
475477 objects: objects,
476478 action: . addObject,
477- waitForTasks: false ,
479+ waitForTasks: waitForTasks ,
478480 batchSize: 1000 ,
479481 requestOptions: requestOptions
480482 )
@@ -484,18 +486,20 @@ public extension SearchClient {
484486 /// creates a `batch` requests with at most 1000 objectIDs in it.
485487 /// - parameter indexName: The name of the index to delete objectIDs from
486488 /// - parameter objectIDs: The objectIDs to delete
489+ /// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one
487490 /// - parameter requestOptions: The request options
488491 /// - returns: [BatchResponse]
489492 func deleteObjects(
490493 indexName: String ,
491494 objectIDs: [ String ] ,
495+ waitForTasks: Bool ? = false ,
492496 requestOptions: RequestOptions ? = nil
493497 ) async throws -> [ BatchResponse ] {
494498 try await self . chunkedBatch (
495499 indexName: indexName,
496500 objects: objectIDs. map { AnyCodable ( [ " objectID " : $0] ) } ,
497501 action: . deleteObject,
498- waitForTasks: false ,
502+ waitForTasks: waitForTasks ,
499503 batchSize: 1000 ,
500504 requestOptions: requestOptions
501505 )
@@ -507,19 +511,21 @@ public extension SearchClient {
507511 /// - parameter objects: The objects to update
508512 /// - parameter createIfNotExists: To be provided if non-existing objects are passed, otherwise, the call will
509513 /// fail..
514+ /// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one
510515 /// - parameter requestOptions: The request options
511516 /// - returns: [BatchResponse]
512517 func partialUpdateObjects(
513518 indexName: String ,
514519 objects: [ some Encodable ] ,
515520 createIfNotExists: Bool = false ,
521+ waitForTasks: Bool ? = false ,
516522 requestOptions: RequestOptions ? = nil
517523 ) async throws -> [ BatchResponse ] {
518524 try await self . chunkedBatch (
519525 indexName: indexName,
520526 objects: objects,
521527 action: createIfNotExists ? . partialUpdateObject : . partialUpdateObjectNoCreate,
522- waitForTasks: false ,
528+ waitForTasks: waitForTasks ,
523529 batchSize: 1000 ,
524530 requestOptions: requestOptions
525531 )
0 commit comments