Using with PHP
A sample PHP application can be found on GitHub https://github.com/searchly/searchly-php-sample.
Installation
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 (
'https://site:api-key@xyz.searchly.com:443'
);
$client = new Elasticsearch\Client($params);
Index Creation
$indexParams['index'] = 'sample';
$client->indices()->create($indexParams);
Search
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';
$client->index($params);
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.