shift31 / laravel-elasticsearch
A Laravel Service Provider for the Elasticsearch API client
Installs: 365 865
Dependents: 1
Suggesters: 0
Security: 0
Stars: 195
Watchers: 12
Forks: 40
Open Issues: 3
Requires
- php: >=5.6
- elasticsearch/elasticsearch: ~5.0
- laravel/framework: ~4.2.0
Requires (Dev)
- mockery/mockery: ^0.9.8
- monolog/monolog: ~1.0
- orchestra/testbench: ^2.2
- phpunit/phpunit: ^5.7
- satooshi/php-coveralls: ^1.0
- squizlabs/php_codesniffer: ^2.8
This package is not auto-updated.
Last update: 2024-11-23 16:08:35 UTC
README
This is a Laravel (4.2) Service Provider for the official Elasticsearch low-level client.
Version Matrix
Since there are breaking changes in Elasticsearch versions, your version of Elasticsearch must match the version of this library, which matches the version of the Elasticsearch low-level client.
Attention: Until we launch new versions please keep using old stable versions (which are created as a branch) and don't use dev-master branch!
Usage
-
Run
composer require shift31/laravel-elasticsearch:~4.5.0
-
Publish config file
Laravel artisan command
$ php artisan config:publish shift31/laravel-elasticsearch
You can always read config parameters with:
\Config::get('shift31::elasticsearch');
Note: The keys of this array should be named according the parameters supported by Elasticsearch\ClientBuilder.
-
In the
'providers'
array in app/config/app.php, add'Shift31\LaravelElasticsearch\ElasticsearchServiceProvider'
. -
Use the
Es
facade to access any method from theElasticsearch\Client
class, for example:
$searchParams['index'] = 'your_index'; $searchParams['size'] = 50; $searchParams['body']['query']['query_string']['query'] = 'foofield:barstring'; $result = Es::search($searchParams);
Default Configuration
If you return an empty array in the config file, Service provider merges default config with custom config variables. For custom config file question please see this elastic search configuration page.
Default config file which is publishing by artisan command.
Contributing
Please see CONTRIBUTING.md.