Skip to content

Commit 50bc69c

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 927e2a6 commit 50bc69c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/Api/SearchClient.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,31 +2945,33 @@ public function replaceAllObjects($indexName, $objects, $batchSize = 1000, $requ
29452945
*
29462946
* @param string $indexName the `indexName` to replace `objects` in
29472947
* @param array $objects the array of `objects` to store in the given Algolia `indexName`
2948+
* @param array $batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
29482949
* @param array $requestOptions Request options
29492950
* @param bool $waitForTasks 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
29502951
*/
2951-
public function saveObjects($indexName, $objects, $requestOptions = [], $waitForTasks = false)
2952+
public function saveObjects($indexName, $objects, $batchSize = 1000, $requestOptions = [], $waitForTasks = false)
29522953
{
2953-
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, 1000, $requestOptions);
2954+
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, $batchSize, $requestOptions);
29542955
}
29552956

29562957
/**
29572958
* Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
29582959
*
29592960
* @param string $indexName the `indexName` to delete `objectIDs` from
29602961
* @param array $objectIDs the `objectIDs` to delete
2962+
* @param array $batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
29612963
* @param array $requestOptions Request options
29622964
* @param bool $waitForTasks 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
29632965
*/
2964-
public function deleteObjects($indexName, $objectIDs, $requestOptions = [], $waitForTasks = false)
2966+
public function deleteObjects($indexName, $objectIDs, $batchSize = 1000, $requestOptions = [], $waitForTasks = false)
29652967
{
29662968
$objects = [];
29672969

29682970
foreach ($objectIDs as $id) {
29692971
$objects[] = ['objectID' => $id];
29702972
}
29712973

2972-
return $this->chunkedBatch($indexName, $objects, 'deleteObject', $waitForTasks, 1000, $requestOptions);
2974+
return $this->chunkedBatch($indexName, $objects, 'deleteObject', $waitForTasks, $batchSize, $requestOptions);
29732975
}
29742976

29752977
/**
@@ -2978,12 +2980,13 @@ public function deleteObjects($indexName, $objectIDs, $requestOptions = [], $wai
29782980
* @param string $indexName the `indexName` to replace `objects` in
29792981
* @param array $objects the array of `objects` to store in the given Algolia `indexName`
29802982
* @param bool $createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
2983+
* @param array $batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
29812984
* @param array $requestOptions Request options
29822985
* @param bool $waitForTasks 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
29832986
*/
2984-
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $requestOptions = [], $waitForTasks = false)
2987+
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $batchSize = 1000, $requestOptions = [], $waitForTasks = false)
29852988
{
2986-
return $this->chunkedBatch($indexName, $objects, (true == $createIfNotExists) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', $waitForTasks, 1000, $requestOptions);
2989+
return $this->chunkedBatch($indexName, $objects, (true == $createIfNotExists) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', $waitForTasks, $batchSize, $requestOptions);
29872990
}
29882991

29892992
/**

0 commit comments

Comments
 (0)