A service provider for laravel with a fluent elasticsearch mapping builder.
composer require triadev/laravel-elasticsearch-mapping
The package is registered through the package discovery of laravel and Composer.
The elasticsearch client is generated via the package: LaravelElasticsearchProvider.
You can find the environment variables for the elasticsearch client in the readme of the package.
This package offers a fluent mapping builder for elasticsearch. The entry point for each mapping build is a facade.
Triadev\Es\Mapping\Facade\ElasticMapping
use Triadev\Es\Mapping\Facade\ElasticMapping;
use Triadev\Es\Mapping\Mapping\Blueprint;
ElasticMapping::map(function (Blueprint $blueprint) {
// fluent syntax
$blueprint->keyword('EXAMPLE')->boost(5);
// attributes array syntax
$blueprint->keyword('EXAMPLE', [
'boost' => 5
]);
// settings are used when creating a new index
$blueprint->settings([
'index' => [
'number_of_replicas' => 10,
'number_of_shards' => 12,
'refresh_interval' => '30s'
]
]);
}, INDEX, TYPE);
If the index does not exist a new index will be created. This also includes the configuration from $blueprint->settings().
If the index exists an update will be executed.
If you do find an issue, please feel free to report it with GitHub's bug tracker for this project.
Alternatively, fork the project and make a pull request. :)
- docker-compose -f docker-compose.yml up
- composer test
Please see CONTRIBUTING for details.
The code for laravel-elasticsearch-mapping is distributed under the terms of the MIT license (see LICENSE).