PHP 클래스 yii\elasticsearch\Connection

부터: 2.0
저자: Carsten Brandt ([email protected])
상속: extends yii\base\Component
파일 보기 프로젝트 열기: yiisoft/yii2-elasticsearch 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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