Skip to content

Commit fc80801

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 617ccb7 commit fc80801

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/algolia/api/search_client.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,17 +3336,18 @@ def get_secured_api_key_remaining_validity(secured_api_key)
33363336
# @param index_name [String]: The `index_name` to save `objects` in.
33373337
# @param objects [Array]: The array of `objects` to store in the given Algolia `indexName`.
33383338
# @param wait_for_tasks [Boolean]: 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.
3339+
# @param batch_size [int] The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
33393340
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
33403341
#
33413342
# @return [BatchResponse]
33423343
#
3343-
def save_objects(index_name, objects, wait_for_tasks = false, request_options = {})
3344+
def save_objects(index_name, objects, wait_for_tasks = false, batch_size = 1000, request_options = {})
33443345
chunked_batch(
33453346
index_name,
33463347
objects,
33473348
Search::Action::ADD_OBJECT,
33483349
wait_for_tasks,
3349-
1000,
3350+
batch_size,
33503351
request_options
33513352
)
33523353
end
@@ -3356,17 +3357,18 @@ def save_objects(index_name, objects, wait_for_tasks = false, request_options =
33563357
# @param index_name [String]: The `index_name` to delete `object_ids` from.
33573358
# @param object_ids [Array]: The object_ids to delete.
33583359
# @param wait_for_tasks [Boolean]: 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.
3360+
# @param batch_size [int] The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
33593361
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
33603362
#
33613363
# @return [BatchResponse]
33623364
#
3363-
def delete_objects(index_name, object_ids, wait_for_tasks = false, request_options = {})
3365+
def delete_objects(index_name, object_ids, wait_for_tasks = false, batch_size = 1000, request_options = {})
33643366
chunked_batch(
33653367
index_name,
33663368
object_ids.map { |id| {"objectID" => id} },
33673369
Search::Action::DELETE_OBJECT,
33683370
wait_for_tasks,
3369-
1000,
3371+
batch_size,
33703372
request_options
33713373
)
33723374
end
@@ -3377,17 +3379,25 @@ def delete_objects(index_name, object_ids, wait_for_tasks = false, request_optio
33773379
# @param objects [Array]: The objects to partially update.
33783380
# @param create_if_not_exists [Boolean]: To be provided if non-existing objects are passed, otherwise, the call will fail.
33793381
# @param wait_for_tasks [Boolean] 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.
3382+
# @param batch_size [int] The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
33803383
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
33813384
#
33823385
# @return [BatchResponse]
33833386
#
3384-
def partial_update_objects(index_name, objects, create_if_not_exists, wait_for_tasks = false, request_options = {})
3387+
def partial_update_objects(
3388+
index_name,
3389+
objects,
3390+
create_if_not_exists,
3391+
wait_for_tasks = false,
3392+
batch_size = 1000,
3393+
request_options = {}
3394+
)
33853395
chunked_batch(
33863396
index_name,
33873397
objects,
33883398
create_if_not_exists ? Search::Action::PARTIAL_UPDATE_OBJECT : Search::Action::PARTIAL_UPDATE_OBJECT_NO_CREATE,
33893399
wait_for_tasks,
3390-
1000,
3400+
batch_size,
33913401
request_options
33923402
)
33933403
end

0 commit comments

Comments
 (0)