Skip to content

Commit 30525a1

Browse files
committed
chore: php
1 parent bf7200d commit 30525a1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

templates/php/api.mustache

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,30 +487,32 @@ use Algolia\AlgoliaSearch\Exceptions\NotFoundException;
487487
*
488488
* @param string $indexName The `indexName` to replace `objects` in.
489489
* @param array $objects The array of `objects` to store in the given Algolia `indexName`.
490+
* @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.
490491
* @param array $requestOptions Request options
491492
* @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
492493
*/
493-
public function saveObjects($indexName, $objects, $requestOptions = [], $waitForTasks = false) {
494-
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, 1000, $requestOptions);
494+
public function saveObjects($indexName, $objects, $batchSize = 1000, $requestOptions = [], $waitForTasks = false) {
495+
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, $batchSize, $requestOptions);
495496
}
496497

497498
/**
498499
* 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.
499500
*
500501
* @param string $indexName The `indexName` to delete `objectIDs` from.
501502
* @param array $objectIDs The `objectIDs` to delete.
503+
* @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.
502504
* @param array $requestOptions Request options
503505
* @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
504506
*/
505-
public function deleteObjects($indexName, $objectIDs, $requestOptions = [], $waitForTasks = false)
507+
public function deleteObjects($indexName, $objectIDs, $batchSize = 1000, $requestOptions = [], $waitForTasks = false)
506508
{
507509
$objects = [];
508510
509511
foreach ($objectIDs as $id) {
510512
$objects[] = ['objectID' => $id];
511513
}
512514

513-
return $this->chunkedBatch($indexName, $objects, 'deleteObject', $waitForTasks, 1000, $requestOptions);
515+
return $this->chunkedBatch($indexName, $objects, 'deleteObject', $waitForTasks, $batchSize, $requestOptions);
514516
}
515517

516518
/**
@@ -519,11 +521,12 @@ use Algolia\AlgoliaSearch\Exceptions\NotFoundException;
519521
* @param string $indexName The `indexName` to replace `objects` in.
520522
* @param array $objects The array of `objects` to store in the given Algolia `indexName`.
521523
* @param bool $createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
524+
* @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.
522525
* @param array $requestOptions Request options
523526
* @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
524527
*/
525-
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $requestOptions = [], $waitForTasks = false) {
526-
return $this->chunkedBatch($indexName, $objects, ($createIfNotExists == TRUE) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', $waitForTasks, 1000, $requestOptions);
528+
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $batchSize = 1000, $requestOptions = [], $waitForTasks = false) {
529+
return $this->chunkedBatch($indexName, $objects, ($createIfNotExists == TRUE) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', $waitForTasks, $batchSize, $requestOptions);
527530
}
528531

529532
/**

0 commit comments

Comments
 (0)