PHP 클래스 Elastica\Client

저자: Nicolas Ruflin ([email protected])
파일 보기 프로젝트 열기: ruflin/elastica 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_callback callback
$_config array log: Set to true, to enable logging, set a string to log to a specific file retryOnConflict: Use in \Elastica\Client::updateDocument bigintConversion: Set to true to enable the JSON bigint to string conversion option (see issue #717)
$_connectionPool Elastica\Connection\ConnectionPool
$_lastRequest Request | null
$_lastResponse Response | null
$_logger Psr\Log\LoggerInterface
$_version string

공개 메소드들

메소드 설명
__construct ( array $config = [], callback $callback = null, Psr\Log\LoggerInterface $logger = null ) Creates a new Elastica client.
addConnection ( Connection $connection )
addDocuments ( array $docs ) : ResponseSet Uses _bulk to send documents to the server.
addHeader ( string $header, string $headerValue ) Adds a HTTP Header.
bulk ( array $params ) : ResponseSet Bulk operation.
connect ( ) Establishes the client connections.
deleteDocuments ( array $docs ) : ResponseSet Bulk deletes documents.
deleteIds ( array $ids, string | Index $index, string | Type $type, string | boolean $routing = false ) : ResponseSet Deletes documents with the given ids, index, type from the index.
getCluster ( ) : Cluster Returns the current cluster.
getConfig ( string $key = '' ) : array | string Returns a specific config key or the whole config array if not set.
getConfigValue ( array | string $keys, mixed $default = null ) : mixed
getConnection ( ) : Connection
getConnectionStrategy ( ) : Elastica\Connection\Strategy\StrategyInterface
getConnections ( ) : Connection[]
getIndex ( string $name ) : Index Returns the index for the given connection.
getLastRequest ( ) : Request | null
getLastResponse ( ) : Response | null
getStatus ( ) : Status Returns the status object for all indices.
getVersion ( ) : string Get current version.
hasConnection ( ) : boolean Determines whether a valid connection is available for use.
optimizeAll ( array $args = [] ) : Response Optimizes all search indices.
refreshAll ( ) : Response Refreshes all search indices.
removeHeader ( string $header ) Remove a HTTP Header.
request ( string $path, string $method = Request::GET, array | string $data = [], array $query = [] ) : Response Makes calls to the elasticsearch server based on this index.
setConfig ( array $config ) Sets specific config values (updates and keeps default values).
setConfigValue ( string $key, mixed $value ) Sets / overwrites a specific config value.
setConnections ( array $connections )
setLogger ( Psr\Log\LoggerInterface $logger ) Replace the existing logger.
updateDocument ( integer | string $id, array | Elastica\Script\AbstractScript | Document $data, string $index, string $type, array $options = [] ) : Response Update document, using update script. Requires elasticsearch >= 0.19.0.
updateDocuments ( array $docs ) : ResponseSet Uses _bulk to send documents to the server.

보호된 메소드들

메소드 설명
_initConnections ( ) Inits the client connections.
_log ( mixed $context ) logging.
_populateDocumentFieldsFromResponse ( Response $response, Document $document, string $fields )
_prepareConnectionParams ( array $config ) : array Creates a Connection params array from a Client or server config array.

메소드 상세

__construct() 공개 메소드

Creates a new Elastica client.
public __construct ( array $config = [], callback $callback = null, Psr\Log\LoggerInterface $logger = null )
$config array OPTIONAL Additional config options
$callback callback OPTIONAL Callback function which can be used to be notified about errors (for example connection down)
$logger Psr\Log\LoggerInterface

_initConnections() 보호된 메소드

Inits the client connections.
protected _initConnections ( )

_log() 보호된 메소드

logging.
사용 중단: Overwriting Client->_log is deprecated. Handle logging functionality by using a custom LoggerInterface.
protected _log ( mixed $context )
$context mixed

_populateDocumentFieldsFromResponse() 보호된 메소드

protected _populateDocumentFieldsFromResponse ( Response $response, Document $document, string $fields )
$response Response
$document Document
$fields string Array of field names to be populated or '_source' if whole document data should be updated

_prepareConnectionParams() 보호된 메소드

Creates a Connection params array from a Client or server config array.
protected _prepareConnectionParams ( array $config ) : array
$config array
리턴 array

addConnection() 공개 메소드

public addConnection ( Connection $connection )
$connection Connection

addDocuments() 공개 메소드

Array of \Elastica\Document as input. Index and type has to be set inside the document, because for bulk settings documents, documents can belong to any type and index
public addDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
리턴 Elastica\Bulk\ResponseSet Response object

addHeader() 공개 메소드

Adds a HTTP Header.
public addHeader ( string $header, string $headerValue )
$header string The HTTP Header
$headerValue string The HTTP Header Value

bulk() 공개 메소드

Every entry in the params array has to exactly on array of the bulk operation. An example param array would be: array( array('index' => array('_index' => 'test', '_type' => 'user', '_id' => '1')), array('user' => array('name' => 'hans')), array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '2')) );
public bulk ( array $params ) : ResponseSet
$params array Parameter array
리턴 Elastica\Bulk\ResponseSet Response object

connect() 공개 메소드

Establishes the client connections.
public connect ( )

deleteDocuments() 공개 메소드

Bulk deletes documents.
public deleteDocuments ( array $docs ) : ResponseSet
$docs array
리턴 Elastica\Bulk\ResponseSet

deleteIds() 공개 메소드

Deletes documents with the given ids, index, type from the index.
public deleteIds ( array $ids, string | Index $index, string | Type $type, string | boolean $routing = false ) : ResponseSet
$ids array Document ids
$index string | Index Index name
$type string | Type Type of documents
$routing string | boolean Optional routing key for all ids
리턴 Elastica\Bulk\ResponseSet Response object

getCluster() 공개 메소드

Returns the current cluster.
public getCluster ( ) : Cluster
리턴 Cluster Cluster object

getConfig() 공개 메소드

Returns a specific config key or the whole config array if not set.
public getConfig ( string $key = '' ) : array | string
$key string Config key
리턴 array | string Config value

getConfigValue() 공개 메소드

public getConfigValue ( array | string $keys, mixed $default = null ) : mixed
$keys array | string config key or path of config keys
$default mixed default value will be returned if key was not found
리턴 mixed

getConnection() 공개 메소드

public getConnection ( ) : Connection
리턴 Connection

getConnectionStrategy() 공개 메소드

public getConnectionStrategy ( ) : Elastica\Connection\Strategy\StrategyInterface
리턴 Elastica\Connection\Strategy\StrategyInterface

getConnections() 공개 메소드

public getConnections ( ) : Connection[]
리턴 Connection[]

getIndex() 공개 메소드

Returns the index for the given connection.
public getIndex ( string $name ) : Index
$name string Index name to create connection to
리턴 Index Index for the given name

getLastRequest() 공개 메소드

public getLastRequest ( ) : Request | null
리턴 Request | null

getLastResponse() 공개 메소드

public getLastResponse ( ) : Response | null
리턴 Response | null

getStatus() 공개 메소드

Returns the status object for all indices.
public getStatus ( ) : Status
리턴 Status Status object

getVersion() 공개 메소드

Get current version.
public getVersion ( ) : string
리턴 string

hasConnection() 공개 메소드

Determines whether a valid connection is available for use.
public hasConnection ( ) : boolean
리턴 boolean

optimizeAll() 공개 메소드

Optimizes all search indices.
public optimizeAll ( array $args = [] ) : Response
$args array OPTIONAL Optional arguments
리턴 Response Response object

refreshAll() 공개 메소드

Refreshes all search indices.
public refreshAll ( ) : Response
리턴 Response Response object

removeHeader() 공개 메소드

Remove a HTTP Header.
public removeHeader ( string $header )
$header string The HTTP Header to remove

request() 공개 메소드

It's possible to make any REST query directly over this method
public request ( string $path, string $method = Request::GET, array | string $data = [], array $query = [] ) : Response
$path string Path to call
$method string Rest method to use (GET, POST, DELETE, PUT)
$data array | string OPTIONAL Arguments as array or pre-encoded string
$query array OPTIONAL Query params
리턴 Response Response object

setConfig() 공개 메소드

Sets specific config values (updates and keeps default values).
public setConfig ( array $config )
$config array Params

setConfigValue() 공개 메소드

Sets / overwrites a specific config value.
public setConfigValue ( string $key, mixed $value )
$key string Key to set
$value mixed Value

setConnections() 공개 메소드

public setConnections ( array $connections )
$connections array

setLogger() 공개 메소드

Replace the existing logger.
public setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

updateDocument() 공개 메소드

Update document, using update script. Requires elasticsearch >= 0.19.0.
public updateDocument ( integer | string $id, array | Elastica\Script\AbstractScript | Document $data, string $index, string $type, array $options = [] ) : Response
$id integer | string document id
$data array | Elastica\Script\AbstractScript | Document raw data for request body
$index string index to update
$type string type of index to update
$options array array of query params to use for query. For possible options check es api
리턴 Response

updateDocuments() 공개 메소드

Array of \Elastica\Document as input. Index and type has to be set inside the document, because for bulk settings documents, documents can belong to any type and index
public updateDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
리턴 Elastica\Bulk\ResponseSet Response object

프로퍼티 상세

$_callback 보호되어 있는 프로퍼티

protected callback $_callback
리턴 callback

$_config 보호되어 있는 프로퍼티

log: Set to true, to enable logging, set a string to log to a specific file retryOnConflict: Use in \Elastica\Client::updateDocument bigintConversion: Set to true to enable the JSON bigint to string conversion option (see issue #717)
protected array $_config
리턴 array

$_connectionPool 보호되어 있는 프로퍼티

protected ConnectionPool,Elastica\Connection $_connectionPool
리턴 Elastica\Connection\ConnectionPool

$_lastRequest 보호되어 있는 프로퍼티

protected Request,Elastica|null $_lastRequest
리턴 Request | null

$_lastResponse 보호되어 있는 프로퍼티

protected Response,Elastica|null $_lastResponse
리턴 Response | null

$_logger 보호되어 있는 프로퍼티

protected LoggerInterface,Psr\Log $_logger
리턴 Psr\Log\LoggerInterface

$_version 보호되어 있는 프로퍼티

protected string $_version
리턴 string