Skip to content
Elastica is a PHP client for elasticsearch
Pull request Compare This branch is 2555 commits behind ruflin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Elastica: elasticsearch PHP Client

PHP client for the distributed search engine elasticsearch which is based on Lucene and can be an alternative to solr. The client naming and structure is consistent with Zend Framework and other PHP frameworks. This makes it easy to use the client in combination with Zend Framework.

With this client I try to model the elasticsearch REST API in an object oriented way which also makes it possible to extend the client and add new types of queries, filters, facets, transport layers and more. The client uses the REST API from elasticsearch and tries to provide a simple way of accessing the elasticsearch functionality. Arguments are passed as arrays which are automatically encoded to JSON which makes it possible to also use not implemented features of the request methods.

Support / Bug Reports

For all support questions please use the Elastica google group.

For But reports and issues please use the issue tracker from github.


For changes in the API please check the file changes.txt


The version numbers are consistent with elasticsearch. The version number means it is the first release for elasticsearch version 0.16.0. The next release is called As soon as the elasticsearch is updated and the client is updated, also the next version is called Like this it should be always clear to which versions the Elastica client is compatible.


Lots of basic examples can also be found in the test classes.

// Creates a new index 'xodoa' and a type 'user' inside this index
$client = new Elastica_Client();    
$index = $client->getIndex('xodoa');
$index->create(array(), true);

$type = $index->getType('user');

// Adds 1 document to the index
$doc1 = new Elastica_Document(1, 
    array('username' => 'hans', 'test' => array('2', '3', '5'))

// Adds a list of documents with _bulk upload to the index
$docs = array();
$docs[] = new Elastica_Document(2, 
    array('username' => 'nicolas', 'test' => array('1', '3', '6'))
$docs[] = new Elastica_Document(3, 
    array('username' => 'ruflin', 'test' => array('2', '3', '7'))

// Index needs a moment to be updated

$resultSet = $type->search('ruflin');

The basic object structure is as following: Client -> Index -> Type -> Document


At the moment the client should be backward compatible to PHP 5.2. That's the reason why the client was not directly built with namespaces and other nice PHP 5.3 features.

File indexing

File upload is supported but the mapper attachement plugin has to be installed

./bin/plugin install mapper-attachments


To all users that gave feedback and committed code

Something went wrong with that request. Please try again.