PHP Класс yii\elasticsearch\Connection

С версии: 2.0
Автор: Carsten Brandt ([email protected])
Наследование: extends yii\base\Component
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$activeNode the active node. Key of one of the [[nodes]]. Will be randomly selected on Connection::open.
$auth Authentication data used to connect to the ElasticSearch node. Array elements: - username: the username for authentication. - password: the password for authentication. Array either MUST contain both username and password on not contain any authentication credentials.
$autodetectCluster whether to autodetect available cluster nodes on Connection::open
$connectionTimeout timeout to use for connecting to an elasticsearch node. This value will be used to configure the curl CURLOPT_CONNECTTIMEOUT option. If not set, no explicit timeout will be set for curl.
$dataTimeout timeout to use when reading the response from an elasticsearch node. This value will be used to configure the curl CURLOPT_TIMEOUT option. If not set, no explicit timeout will be set for curl.
$defaultProtocol If [[autodetectCluster]] is true, all nodes received from cluster will be set to use the protocol defined by [[defaultProtocol]]
$nodes The elasticsearch cluster nodes to connect to. This is populated with the result of a cluster nodes request when [[autodetectCluster]] is true. Additional special options: - auth: overrides [[auth]] property. For example: php [ 'http_address' => 'inet[/127.0.0.1:9200]', 'auth' => ['username' => 'yiiuser', 'password' => 'yiipw'], // Overrides the auth property of the class with specific login and password 'auth' => ['username' => 'yiiuser', 'password' => 'yiipw'], // Disabled auth regardless of auth property of the class ] - protocol: explicitly sets the protocol for the current node (useful when manually defining a HTTPS cluster)

Открытые методы

Метод Описание
__sleep ( ) : array Closes the connection when this component is being serialized.
close ( ) Closes the currently active DB connection.
createBulkCommand ( array $config = [] ) : BulkCommand Creates a bulk command for execution.
createCommand ( array $config = [] ) : Command Creates a command for execution.
delete ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed Performs DELETE HTTP request
get ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed Performs GET HTTP request
getClusterState ( )
getDriverName ( ) : string Returns the name of the DB driver for the current [[dsn]].
getIsActive ( ) : boolean Returns a value indicating whether the DB connection is established.
getNodeInfo ( )
getQueryBuilder ( ) : QueryBuilder Creates new query builder instance
head ( string | array $url, array $options = [], string $body = null ) : mixed Performs HEAD HTTP request
init ( )
open ( ) Establishes a DB connection.
post ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed Performs POST HTTP request
put ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed Performs PUT HTTP request

Защищенные методы

Метод Описание
decodeErrorBody ( $body ) : mixed Try to decode error information if it is valid json, return it if not.
httpRequest ( string $method, string $url, string $requestBody = null, boolean $raw = false ) : mixed Performs HTTP request
initConnection ( ) Initializes the DB connection.
populateNodes ( ) Populates [[nodes]] with the result of a cluster nodes request.
selectActiveNode ( ) select active node randomly

Приватные методы

Метод Описание
createUrl ( string | array $path, array $options = [] ) : array Creates URL
resetCurlHandle ( )

Описание методов

__sleep() публичный метод

Closes the connection when this component is being serialized.
public __sleep ( ) : array
Результат array

close() публичный метод

It does nothing if the connection is already closed.
public close ( )

createBulkCommand() публичный метод

Creates a bulk command for execution.
С версии: 2.0.5
public createBulkCommand ( array $config = [] ) : BulkCommand
$config array the configuration for the [[BulkCommand]] class
Результат BulkCommand the DB command

createCommand() публичный метод

Creates a command for execution.
public createCommand ( array $config = [] ) : Command
$config array the configuration for the Command class
Результат Command the DB command

decodeErrorBody() защищенный метод

Try to decode error information if it is valid json, return it if not.
protected decodeErrorBody ( $body ) : mixed
$body
Результат mixed

delete() публичный метод

Performs DELETE HTTP request
public delete ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed
$url string | array URL
$options array URL options
$body string request body
$raw boolean if response body contains JSON and should be decoded
Результат mixed response

get() публичный метод

Performs GET HTTP request
public get ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed
$url string | array URL
$options array URL options
$body string request body
$raw boolean if response body contains JSON and should be decoded
Результат mixed response

getClusterState() публичный метод

public getClusterState ( )

getDriverName() публичный метод

Returns the name of the DB driver for the current [[dsn]].
public getDriverName ( ) : string
Результат string name of the DB driver

getIsActive() публичный метод

Returns a value indicating whether the DB connection is established.
public getIsActive ( ) : boolean
Результат boolean whether the DB connection is established

getNodeInfo() публичный метод

public getNodeInfo ( )

getQueryBuilder() публичный метод

Creates new query builder instance
public getQueryBuilder ( ) : QueryBuilder
Результат QueryBuilder

head() публичный метод

Performs HEAD HTTP request
public head ( string | array $url, array $options = [], string $body = null ) : mixed
$url string | array URL
$options array URL options
$body string request body
Результат mixed response

httpRequest() защищенный метод

Performs HTTP request
protected httpRequest ( string $method, string $url, string $requestBody = null, boolean $raw = false ) : mixed
$method string method name
$url string URL
$requestBody string request body
$raw boolean if response body contains JSON and should be decoded
Результат mixed if request failed

init() публичный метод

public init ( )

initConnection() защищенный метод

This method is invoked right after the DB connection is established. The default implementation triggers an [[EVENT_AFTER_OPEN]] event.
protected initConnection ( )

open() публичный метод

It does nothing if a DB connection has already been established.
public open ( )

populateNodes() защищенный метод

Populates [[nodes]] with the result of a cluster nodes request.
С версии: 2.0.4
protected populateNodes ( )

post() публичный метод

Performs POST HTTP request
public post ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed
$url string | array URL
$options array URL options
$body string request body
$raw boolean if response body contains JSON and should be decoded
Результат mixed response

put() публичный метод

Performs PUT HTTP request
public put ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed
$url string | array URL
$options array URL options
$body string request body
$raw boolean if response body contains JSON and should be decoded
Результат mixed response

selectActiveNode() защищенный метод

select active node randomly
protected selectActiveNode ( )

Описание свойств

$activeNode публичное свойство

the active node. Key of one of the [[nodes]]. Will be randomly selected on Connection::open.
public $activeNode

$auth публичное свойство

Authentication data used to connect to the ElasticSearch node. Array elements: - username: the username for authentication. - password: the password for authentication. Array either MUST contain both username and password on not contain any authentication credentials.
См. также: http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html#_example_configuring_http_basic_auth
public $auth

$autodetectCluster публичное свойство

whether to autodetect available cluster nodes on Connection::open
public $autodetectCluster

$connectionTimeout публичное свойство

timeout to use for connecting to an elasticsearch node. This value will be used to configure the curl CURLOPT_CONNECTTIMEOUT option. If not set, no explicit timeout will be set for curl.
public $connectionTimeout

$dataTimeout публичное свойство

timeout to use when reading the response from an elasticsearch node. This value will be used to configure the curl CURLOPT_TIMEOUT option. If not set, no explicit timeout will be set for curl.
public $dataTimeout

$defaultProtocol публичное свойство

If [[autodetectCluster]] is true, all nodes received from cluster will be set to use the protocol defined by [[defaultProtocol]]
С версии: 2.0.5
public $defaultProtocol

$nodes публичное свойство

The elasticsearch cluster nodes to connect to. This is populated with the result of a cluster nodes request when [[autodetectCluster]] is true. Additional special options: - auth: overrides [[auth]] property. For example: php [ 'http_address' => 'inet[/127.0.0.1:9200]', 'auth' => ['username' => 'yiiuser', 'password' => 'yiipw'], // Overrides the auth property of the class with specific login and password 'auth' => ['username' => 'yiiuser', 'password' => 'yiipw'], // Disabled auth regardless of auth property of the class ] - protocol: explicitly sets the protocol for the current node (useful when manually defining a HTTPS cluster)
См. также: http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html#cluster-nodes-info
public $nodes