include/SugarSearchEngine/Elastic/Elastica/Client.php

Show: inherited
Table of Contents

Client to connect the the elasticsearch server

Author
Nicolas Ruflin  
Category
Xodoa  
Package
Elastica  

\Elastica_Client

Package: Elastica

Client to connect the the elasticsearch server

Author
Nicolas Ruflin  
Category
Xodoa  

Constants

Constant  DEFAULT_PORT = 9200

Default elastic search port

Constant  DEFAULT_HOST = 'localhost'

Default host

Constantstring  DEFAULT_TRANSPORT = 'Http'

Default transport

string
Constant  TIMEOUT = 300

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

Properties

Propertyprotectedarray  $_config= 'array( 'host' => self::DEFAULT_HOST, 'port' => self::DEFAULT_PORT, 'transport' => self::DEFAULT_TRANSPORT, 'timeout' => self::TIMEOUT, 'headers' => array(), 'servers' => array(), 'roundRobin' => false, 'log' => false, )'

Config with defaults

Default valuearray( 'host' => self::DEFAULT_HOST, 'port' => self::DEFAULT_PORT, 'transport' => self::DEFAULT_TRANSPORT, 'timeout' => self::TIMEOUT, 'headers' => array(), 'servers' => array(), 'roundRobin' => false, 'log' => false, )Details
Type
array

Methods

methodpublic__construct( array $config = array() ) : void

Creates a new Elastica client

Parameters
Name Type Description
$config array

OPTIONAL Additional config options

methodpublicaddDocuments( array $docs ) : \Elastica_Response

Uses _bulk to send documents to the server

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

Parameters
Name Type Description
$docs array

Array of Elastica_Document

Returns
Type Description
\Elastica_Response Response object
Throws
Exception Description
\Elastica_Exception_Invalid If docs is empty
Details
Link
http://www.elasticsearch.com/docs/elasticsearch/rest_api/bulk/  
methodpublicaddHeader( string $header, string $headerValue ) : void

Adds a HTTP Header

Parameters
Name Type Description
$header string

The HTTP Header

$headerValue string

The HTTP Header Value

Throws
Exception Description
\Elastica_Exception_Invalid If $header or $headerValue is not a string
methodpublicbulk( array $params ) : \Elastica_Response

Bulk operation

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')) );

Parameters
Name Type Description
$params array

Parameter array

Returns
Type Description
\Elastica_Response Reponse object
Details
Link
http://www.elasticsearch.com/docs/elasticsearch/rest_api/bulk/  
Todo
Test  
methodpublicdeleteDocuments( array $docs ) : void

Bulk deletes documents (not implemented yet)

Parameters
Name Type Description
$docs array

Docs

Throws
Exception Description
\Elastica_Exception
methodpublicdeleteIds( array $ids, string | \Elastica_Index $index, string | \Elastica_Type $type ) : \Elastica_Response

Deletes documents with the given ids, index, type from the index

Parameters
Name Type Description
$ids array

Document ids

$index string | \Elastica_Index

Index name

$type string | \Elastica_Type

Type of documents

Returns
Type Description
\Elastica_Response Response object
Throws
Exception Description
\Elastica_Exception If ids is empty
Details
Link
http://www.elasticsearch.com/docs/elasticsearch/rest_api/bulk/  
methodpublicgetCluster( ) : \Elastica_Cluster

Returns the current cluster

Returns
Type Description
\Elastica_Cluster Cluster object
methodpublicgetConfig( string $key = '' ) : array | string

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

Parameters
Name Type Description
$key string

Config key

Returns
Type Description
array | string Config value
methodpublicgetHost( ) : string

Returns host the client connects to

Returns
Type Description
string Host
methodpublicgetIndex( string $name ) : \Elastica_Index

Returns the index for the given connection

Parameters
Name Type Description
$name string

Index name to create connection to

Returns
Type Description
\Elastica_Index Index for the given name
methodpublicgetPort( ) : int

Returns connection port of this client

Returns
Type Description
int Connection port
methodpublicgetStatus( ) : \Elastica_Status

Returns the status object for all indices

Returns
Type Description
\Elastica_Status Status object
methodpublicgetTransport( ) : string

Returns transport type to user

Returns
Type Description
string Transport type
methodpublicoptimizeAll( array $args = array() ) : \Elastica_Response

Optimizes all search indices

Parameters
Name Type Description
$args array

OPTIONAL Optional arguments

Returns
Type Description
\Elastica_Response Response object
Details
Link
http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/optimize/  
methodpublicremoveHeader( string $header ) : void

Remove a HTTP Header

Parameters
Name Type Description
$header string

The HTTP Header to remove

Throws
Exception Description
\Elastica_Exception_Invalid IF $header is not a string
methodpublicrequest( string $path, string $method, array $data = array() ) : \Elastica_Response

Makes calls to the elasticsearch server based on this index

It's possible to make any REST query directly over this method

Parameters
Name Type Description
$path string

Path to call

$method string

Rest method to use (GET, POST, DELETE, PUT)

$data array

OPTIONAL Arguments as array

Returns
Type Description
\Elastica_Response Response object
methodpublicsetConfig( array $config ) : void

Sets specific config values (updates and keeps default values)

Parameters
Name Type Description
$config array

Params

methodpublicsetConfigValue( string $key, mixed $value ) : \Elastica_Client

Sets / overwrites a specific config value

Parameters
Name Type Description
$key string

Key to set

$value mixed

Value

Returns
Type Description
\Elastica_Client Client object
Documentation was generated by DocBlox 0.18.1.