Skip to content

Commit

Permalink
feat(clients): allow batch size on objects helper [skip-bc] (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4172

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Nov 29, 2024
1 parent 617ccb7 commit fc80801
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/algolia/api/search_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3336,17 +3336,18 @@ def get_secured_api_key_remaining_validity(secured_api_key)
# @param index_name [String]: The `index_name` to save `objects` in.
# @param objects [Array]: The array of `objects` to store in the given Algolia `indexName`.
# @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.
# @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.
# @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)
#
# @return [BatchResponse]
#
def save_objects(index_name, objects, wait_for_tasks = false, request_options = {})
def save_objects(index_name, objects, wait_for_tasks = false, batch_size = 1000, request_options = {})
chunked_batch(
index_name,
objects,
Search::Action::ADD_OBJECT,
wait_for_tasks,
1000,
batch_size,
request_options
)
end
Expand All @@ -3356,17 +3357,18 @@ def save_objects(index_name, objects, wait_for_tasks = false, request_options =
# @param index_name [String]: The `index_name` to delete `object_ids` from.
# @param object_ids [Array]: The object_ids to delete.
# @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.
# @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.
# @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)
#
# @return [BatchResponse]
#
def delete_objects(index_name, object_ids, wait_for_tasks = false, request_options = {})
def delete_objects(index_name, object_ids, wait_for_tasks = false, batch_size = 1000, request_options = {})
chunked_batch(
index_name,
object_ids.map { |id| {"objectID" => id} },
Search::Action::DELETE_OBJECT,
wait_for_tasks,
1000,
batch_size,
request_options
)
end
Expand All @@ -3377,17 +3379,25 @@ def delete_objects(index_name, object_ids, wait_for_tasks = false, request_optio
# @param objects [Array]: The objects to partially update.
# @param create_if_not_exists [Boolean]: To be provided if non-existing objects are passed, otherwise, the call will fail.
# @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.
# @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.
# @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)
#
# @return [BatchResponse]
#
def partial_update_objects(index_name, objects, create_if_not_exists, wait_for_tasks = false, request_options = {})
def partial_update_objects(
index_name,
objects,
create_if_not_exists,
wait_for_tasks = false,
batch_size = 1000,
request_options = {}
)
chunked_batch(
index_name,
objects,
create_if_not_exists ? Search::Action::PARTIAL_UPDATE_OBJECT : Search::Action::PARTIAL_UPDATE_OBJECT_NO_CREATE,
wait_for_tasks,
1000,
batch_size,
request_options
)
end
Expand Down

0 comments on commit fc80801

Please sign in to comment.