- PHP Client: other versions:
- Overview
- Quickstart
- Installation
- Configuration
- Inline Host Configuration
- Extended Host Configuration
- Authorization and Encryption
- Set retries
- Enabling the Logger
- Configure the HTTP Handler
- Setting the Connection Pool
- Setting the Connection Selector
- Setting the Serializer
- Setting a custom ConnectionFactory
- Set the Endpoint closure
- Building the client from a configuration hash
- Per-request configuration
- Future Mode
- Dealing with JSON Arrays and Objects in PHP
- Index Management Operations
- Indexing Documents
- Getting Documents
- Updating Documents
- Deleting documents
- Search Operations
- Namespaces
- Security
- Connection Pool
- Selectors
- Serializers
- PHP Version Requirement
- Breaking changes from 5.x
- Community DSLs
- Community Integrations
- Reference - Endpoints
- Elasticsearch\Client
- Elasticsearch\ClientBuilder
- Elasticsearch\Namespaces\CatNamespace
- Elasticsearch\Namespaces\ClusterNamespace
- Elasticsearch\Namespaces\IndicesNamespace
- Elasticsearch\Namespaces\IngestNamespace
- Elasticsearch\Namespaces\NodesNamespace
- Elasticsearch\Namespaces\RemoteNamespace
- Elasticsearch\Namespaces\SnapshotNamespace
- Elasticsearch\Namespaces\TasksNamespace
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Changing batch size
editChanging batch size
editThe default batch size is 100, meaning 100 requests will queue up before the client forces futures to begin resolving
(e.g. initiate a curl_multi
call). The batch size can be changed depending on your preferences. The batch size
is controllable via the max_handles
setting when configuring the handler:
$handlerParams = [ 'max_handles' => 500 ]; $defaultHandler = ClientBuilder::defaultHandler($handlerParams); $client = ClientBuilder::create() ->setHandler($defaultHandler) ->build();
This will change the behavior to wait on 500 queued requests before sending the batch. Note, however, that forcing a future to resolve will cause the underlying curl batch to execute, regardless of if the batch is "full" or not. In this example, only 499 requests are added to the queue…but the final future resolution will force the batch to flush anyway:
$handlerParams = [ 'max_handles' => 500 ]; $defaultHandler = ClientBuilder::defaultHandler($handlerParams); $client = ClientBuilder::create() ->setHandler($defaultHandler) ->build(); $futures = []; for ($i = 0; $i < 499; $i++) { $params = [ 'index' => 'test', 'type' => 'test', 'id' => $i, 'client' => [ 'future' => 'lazy' ] ]; $futures[] = $client->get($params); //queue up the request } // resolve the future, and therefore the underlying batch $body = $future[499]['body'];
Was this helpful?
Thank you for your feedback.