- PHP Client: other versions:
- Overview
- Quickstart
- Installation
- Configuration
- Index Operations
- Indexing Operations
- Search Operations
- The Connection Pool
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Example: Configuring the Hosts
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Example: Configuring the Hosts
editA common operation will be telling the client what nodes are in your cluster. By default, the client will connect to localhost:9200, which obviously doesn’t work in many production environments.
All configurations (both simple parameters and more advanced component-replacement) are injected into the constructor of the client.
The client accepts an array of hosts that you would like to connect to. Each value in the array must be a string (either with or without the port number):
$params = array(); $params['hosts'] = array ( '192.168.1.1:9200', // IP + Port '192.168.1.2', // Just IP 'mydomain.server.com:9201', // Domain + Port 'mydomain2.server.com' // Just Domain ); $client = new Elasticsearch\Client($params);
This associative array holds all custom configurations that you may want to set. Often, you’ll only need to configure the hosts, but if you need more advanced behavior, read on.
Was this helpful?
Thank you for your feedback.