Constants

DEFAULT_PORT

DEFAULT_PORT

Default elastic search port.

DEFAULT_HOST

DEFAULT_HOST

Default host.

DEFAULT_TRANSPORT

DEFAULT_TRANSPORT

Default transport.

DEFAULT_COMPRESSION

DEFAULT_COMPRESSION

Default compression.

TIMEOUT

TIMEOUT

Number of seconds after a timeout occurs for every request If using indexing of file large value necessary.

CONNECT_TIMEOUT

CONNECT_TIMEOUT

Number of seconds after a connection timeout occurs for every request during the connection phase.

Properties

$_params

$_params : array

Params.

Type

array

$_rawParams

$_rawParams : array

Raw Params.

Type

array

Methods

toArray()

toArray() : array

Converts the params to an array. A default implementation exist to create the an array out of the class name (last part of the class name) and the params.

Returns

array —

Filter array

setParam()

setParam(string  $key, mixed  $value) : $this

Sets (overwrites) the value at the given key.

Parameters

string $key

Key to set

mixed $value

Key Value

Returns

$this

setParams()

setParams(array  $params) : $this

Sets (overwrites) all params of this object.

Parameters

array $params

Parameter list

Returns

$this

addParam()

addParam(string  $key, mixed  $value) : $this

Adds a param to the list.

This function can be used to add an array of params

Parameters

string $key

Param key

mixed $value

Value to set

Returns

$this

getParam()

getParam(string  $key) : mixed

Returns a specific param.

Parameters

string $key

Key to return

Throws

\Elastica\Exception\InvalidException

If requested key is not set

Returns

mixed —

Key value

hasParam()

hasParam(string  $key) : boolean

Test if a param is set.

Parameters

string $key

Key to test

Returns

boolean —

True if the param is set, false otherwise

getParams()

getParams() : array

Returns the params array.

Returns

array —

Params

__construct()

__construct(array  $params = array()) 

Creates a new connection object. A connection is enabled by default.

Parameters

array $params

OPTIONAL Connection params: host, port, transport, timeout. All are optional

getPort()

getPort() : integer

Returns

integer —

Server port

setPort()

setPort(integer  $port) : $this

Parameters

integer $port

Returns

$this

getHost()

getHost() : string

Returns

string —

Host

setHost()

setHost(string  $host) : $this

Parameters

string $host

Returns

$this

getProxy()

getProxy() : string|null

Returns

string|null —

Host

setProxy()

setProxy(string|null  $proxy) : $this

Set proxy for http connections. Null is for environmental proxy, empty string to disable proxy and proxy string to set actual http proxy.

Parameters

string|null $proxy

Returns

$this

getTransport()

getTransport() : string|array

Returns

string|array

setTransport()

setTransport(string|array  $transport) : $this

Parameters

string|array $transport

Returns

$this

hasCompression()

hasCompression() : boolean

Returns

boolean

setCompression()

setCompression(boolean  $compression = null) : $this

Parameters

boolean $compression

Returns

$this

getPath()

getPath() : string

Returns

string

setPath()

setPath(string  $path) : $this

Parameters

string $path

Returns

$this

setTimeout()

setTimeout(integer  $timeout) : $this

Parameters

integer $timeout

Timeout in seconds

Returns

$this

getTimeout()

getTimeout() : integer

Returns

integer —

Connection timeout in seconds

setConnectTimeout()

setConnectTimeout(integer  $timeout) : $this

Number of seconds after a connection timeout occurs for every request during the connection phase.

Use a small value if you need a fast fail in case of dead, unresponsive or unreachable servers (~5 sec).

Set to zero to switch to the default built-in connection timeout (300 seconds in curl).

Parameters

integer $timeout

Connect timeout in seconds

Returns

$this

getConnectTimeout()

getConnectTimeout() : integer

Returns

integer —

Connection timeout in seconds

setEnabled()

setEnabled(boolean  $enabled = true) : $this

Enables a connection.

Parameters

boolean $enabled

OPTIONAL (default = true)

Returns

$this

isEnabled()

isEnabled() : boolean

Returns

boolean —

True if enabled

getTransportObject()

getTransportObject() : \Elastica\Transport\AbstractTransport

Returns an instance of the transport type.

Throws

\Elastica\Exception\InvalidException

If invalid transport type

Returns

\Elastica\Transport\AbstractTransport

Transport object

isPersistent()

isPersistent() : boolean

Returns

boolean —

Returns true if connection is persistent. True by default

setConfig()

setConfig(array  $config) : $this

Parameters

array $config

Returns

$this

addConfig()

addConfig(string  $key, mixed  $value) : $this

Parameters

string $key
mixed $value

Returns

$this

hasConfig()

hasConfig(string  $key) : boolean

Parameters

string $key

Returns

boolean

getConfig()

getConfig(string  $key = '') : array|string

Returns a specific config key or the whole config array if not set.

Parameters

string $key

Config key

Throws

\Elastica\Exception\InvalidException

Returns

array|string —

Config value

create()

create(\Elastica\Connection|array  $params = array()) : self

Parameters

\Elastica\Connection|array $params

Params to create a connection

Throws

\Elastica\Exception\InvalidException

Returns

self

getUsername()

getUsername() : string

Returns

string —

User

getPassword()

getPassword() : string

Returns

string —

Password

_convertArrayable()

_convertArrayable(array  $array) : array

Cast objects to arrays.

Parameters

array $array

Returns

array

_getBaseName()

_getBaseName() : string

Param's name Picks the last part of the class name and makes it snake_case You can override this method if you want to change the name.

Returns

string —

name

_setRawParam()

_setRawParam(string  $key, mixed  $value) : $this

Sets params not inside params array.

Parameters

string $key
mixed $value

Returns

$this