Skip to content

Commit 91f350b

Browse files
feat(clients): allow batch size on objects helper [skip-bc] (generated)
algolia/api-clients-automation#4172 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 94ffc75 commit 91f350b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sources/Search/Extra/SearchClientExtension.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,20 +468,22 @@ public extension SearchClient {
468468
/// - parameter indexName: The name of the index where to save the objects
469469
/// - parameter objects: The new objects
470470
/// - 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
471472
/// - parameter requestOptions: The request options
472473
/// - returns: [BatchResponse]
473474
func saveObjects(
474475
indexName: String,
475476
objects: [some Encodable],
476477
waitForTasks: Bool = false,
478+
batchSize: Int = 1000,
477479
requestOptions: RequestOptions? = nil
478480
) async throws -> [BatchResponse] {
479481
try await self.chunkedBatch(
480482
indexName: indexName,
481483
objects: objects,
482484
action: .addObject,
483485
waitForTasks: waitForTasks,
484-
batchSize: 1000,
486+
batchSize: batchSize,
485487
requestOptions: requestOptions
486488
)
487489
}
@@ -491,20 +493,22 @@ public extension SearchClient {
491493
/// - parameter indexName: The name of the index to delete objectIDs from
492494
/// - parameter objectIDs: The objectIDs to delete
493495
/// - 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
494497
/// - parameter requestOptions: The request options
495498
/// - returns: [BatchResponse]
496499
func deleteObjects(
497500
indexName: String,
498501
objectIDs: [String],
499502
waitForTasks: Bool = false,
503+
batchSize: Int = 1000,
500504
requestOptions: RequestOptions? = nil
501505
) async throws -> [BatchResponse] {
502506
try await self.chunkedBatch(
503507
indexName: indexName,
504508
objects: objectIDs.map { AnyCodable(["objectID": $0]) },
505509
action: .deleteObject,
506510
waitForTasks: waitForTasks,
507-
batchSize: 1000,
511+
batchSize: batchSize,
508512
requestOptions: requestOptions
509513
)
510514
}
@@ -516,21 +520,23 @@ public extension SearchClient {
516520
/// - parameter createIfNotExists: To be provided if non-existing objects are passed, otherwise, the call will
517521
/// fail..
518522
/// - 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
519524
/// - parameter requestOptions: The request options
520525
/// - returns: [BatchResponse]
521526
func partialUpdateObjects(
522527
indexName: String,
523528
objects: [some Encodable],
524529
createIfNotExists: Bool = false,
525530
waitForTasks: Bool = false,
531+
batchSize: Int = 1000,
526532
requestOptions: RequestOptions? = nil
527533
) async throws -> [BatchResponse] {
528534
try await self.chunkedBatch(
529535
indexName: indexName,
530536
objects: objects,
531537
action: createIfNotExists ? .partialUpdateObject : .partialUpdateObjectNoCreate,
532538
waitForTasks: waitForTasks,
533-
batchSize: 1000,
539+
batchSize: batchSize,
534540
requestOptions: requestOptions
535541
)
536542
}

0 commit comments

Comments
 (0)