- 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.
Increasing the Verbosity of responses
editIncreasing the Verbosity of responses
editBy default, the client will only return the response body. If you require more information (e.g. stats about the transfer,
headers, status codes, etc), you can tell the client to return a more verbose response. This is enabled via the
verbose
parameter in the client options.
Without verbosity, all you see is the response body:
$client = ClientBuilder::create()->build(); $params = [ 'index' => 'test', 'type' => 'test', 'id' => 1 ]; $response = $client->get($params); print_r($response); Array ( [_index] => test [_type] => test [_id] => 1 [_version] => 1 [found] => 1 [_source] => Array ( [field] => value ) )
With verbosity turned on, you will see all of the transfer stats:
$client = ClientBuilder::create()->build(); $params = [ 'index' => 'test', 'type' => 'test', 'id' => 1, 'client' => [ 'verbose' => true ] ]; $response = $client->get($params); print_r($response); Array ( [transfer_stats] => Array ( [url] => http://127.0.0.1:9200/test/test/1 [content_type] => application/json; charset=UTF-8 [http_code] => 200 [header_size] => 86 [request_size] => 51 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.00289 [namelookup_time] => 9.7E-5 [connect_time] => 0.000265 [pretransfer_time] => 0.000322 [size_upload] => 0 [size_download] => 96 [speed_download] => 33217 [speed_upload] => 0 [download_content_length] => 96 [upload_content_length] => -1 [starttransfer_time] => 0.002796 [redirect_time] => 0 [redirect_url] => [primary_ip] => 127.0.0.1 [certinfo] => Array ( ) [primary_port] => 9200 [local_ip] => 127.0.0.1 [local_port] => 62971 ) [curl] => Array ( [error] => [errno] => 0 ) [effective_url] => http://127.0.0.1:9200/test/test/1 [headers] => Array ( [Content-Type] => Array ( [0] => application/json; charset=UTF-8 ) [Content-Length] => Array ( [0] => 96 ) ) [status] => 200 [reason] => OK [body] => Array ( [_index] => test [_type] => test [_id] => 1 [_version] => 1 [found] => 1 [_source] => Array ( [field] => value ) ) )
Was this helpful?
Thank you for your feedback.