@@ -468,20 +468,22 @@ public extension SearchClient {
468
468
/// - parameter indexName: The name of the index where to save the objects
469
469
/// - parameter objects: The new objects
470
470
/// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one
471
+ /// - parameter batchSize: The maximum number of objects to include in a batch
471
472
/// - parameter requestOptions: The request options
472
473
/// - returns: [BatchResponse]
473
474
func saveObjects(
474
475
indexName: String ,
475
476
objects: [ some Encodable ] ,
476
477
waitForTasks: Bool = false ,
478
+ batchSize: Int = 1000 ,
477
479
requestOptions: RequestOptions ? = nil
478
480
) async throws -> [ BatchResponse ] {
479
481
try await self . chunkedBatch (
480
482
indexName: indexName,
481
483
objects: objects,
482
484
action: . addObject,
483
485
waitForTasks: waitForTasks,
484
- batchSize: 1000 ,
486
+ batchSize: batchSize ,
485
487
requestOptions: requestOptions
486
488
)
487
489
}
@@ -491,20 +493,22 @@ public extension SearchClient {
491
493
/// - parameter indexName: The name of the index to delete objectIDs from
492
494
/// - parameter objectIDs: The objectIDs to delete
493
495
/// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one
496
+ /// - parameter batchSize: The maximum number of objects to include in a batch
494
497
/// - parameter requestOptions: The request options
495
498
/// - returns: [BatchResponse]
496
499
func deleteObjects(
497
500
indexName: String ,
498
501
objectIDs: [ String ] ,
499
502
waitForTasks: Bool = false ,
503
+ batchSize: Int = 1000 ,
500
504
requestOptions: RequestOptions ? = nil
501
505
) async throws -> [ BatchResponse ] {
502
506
try await self . chunkedBatch (
503
507
indexName: indexName,
504
508
objects: objectIDs. map { AnyCodable ( [ " objectID " : $0] ) } ,
505
509
action: . deleteObject,
506
510
waitForTasks: waitForTasks,
507
- batchSize: 1000 ,
511
+ batchSize: batchSize ,
508
512
requestOptions: requestOptions
509
513
)
510
514
}
@@ -516,21 +520,23 @@ public extension SearchClient {
516
520
/// - parameter createIfNotExists: To be provided if non-existing objects are passed, otherwise, the call will
517
521
/// fail..
518
522
/// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one
523
+ /// - parameter batchSize: The maximum number of objects to include in a batch
519
524
/// - parameter requestOptions: The request options
520
525
/// - returns: [BatchResponse]
521
526
func partialUpdateObjects(
522
527
indexName: String ,
523
528
objects: [ some Encodable ] ,
524
529
createIfNotExists: Bool = false ,
525
530
waitForTasks: Bool = false ,
531
+ batchSize: Int = 1000 ,
526
532
requestOptions: RequestOptions ? = nil
527
533
) async throws -> [ BatchResponse ] {
528
534
try await self . chunkedBatch (
529
535
indexName: indexName,
530
536
objects: objects,
531
537
action: createIfNotExists ? . partialUpdateObject : . partialUpdateObjectNoCreate,
532
538
waitForTasks: waitForTasks,
533
- batchSize: 1000 ,
539
+ batchSize: batchSize ,
534
540
requestOptions: requestOptions
535
541
)
536
542
}
0 commit comments