dev-master
9999999-devA Laravel 4 Service Provider for the Elasticsearch API client
The Requires
by Shift 31 Consulting
Wallogit.com
2017 © Pedro Peláez
A Laravel 4 Service Provider for the Elasticsearch API client
This is a Laravel 4 Service Provider for the offical Elasticsearch API client: http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html, (*1)
Require "shift31/laravel-elasticsearch": "dev-master" in your composer.json, (*2)
Create app/config/elasticsearch.php, modifying the following contents accordingly:, (*3)
return array(
'hosts' => array(
'your.elasticsearch.server:9200'
),
'logPath' => 'path/to/your/elasticsearch/log'
'logLevel' => Logger::INFO;
);
Add 'Shift31\LaravelElasticsearch\LaravelElasticsearchServiceProvider' to your 'providers' array in app/config/app.php, (*4)
Use the Es facade to access any method from the Elasticsearch\Client class, for example:, (*5)
$searchParams['index'] = 'your_index'; $searchParams['size'] = 50; $searchParams['body']['query']['query_string']['query'] = 'foofield:barstring'; $result = Es::search($searchParams);
If you return an empty array in the config file:, (*6)
'hosts' defaults to localhost:9200, (*7)
'logPath' defaults to storage_path() . '/logs/hostbase-elasticsearch-' . php_sapi_name() . '.log', (*8)
'logLevel' defaults to Logger::INFO, (*9)
A Laravel 4 Service Provider for the Elasticsearch API client