A sample PHP application can be found on GitHub https://github.com/searchly/searchly-php-sample.


Documentation targets official PHP client for Elasticsearch

Add elasticsearch client dependency to your composer.json file and ;

"require": {
"elasticsearch/elasticsearch": "~1.0"

Update application dependencies with composer;

$ php composer.phar install

Create Client

$params['hosts'] = array (
$client = new Elasticsearch\Client($params);

Index Creation

$indexParams['index']  = 'sample';


Index a document;

$document = array(
name => 'Reliability',
text => 'Reliability is improved if multiple redundant sites are used, which makes well-designed cloud computing suitable for business continuity.'
$params = array();
$params['body'] = $document;
$params['index'] = 'sample';
$params['type'] = 'document';

You can search indexed document as:

$searchParams['body']['query']['match']['text'] = 'Reliability';
$results = $client->search($searchParams);

Useful Resources

PHP client has very detailed documentation at official Elasticsearch site.