triadev / laravel-elasticsearch-mapping
A service provider for laravel with a fluent elasticsearch mapping builder.
Requires
- php: >=7.1
- ext-json: *
- elasticsearch/elasticsearch: ^6.0
- illuminate/support: 5.5.* || 5.6.* || 5.7.*
- triadev/laravel-elasticsearch-provider: ^3.0
Requires (Dev)
- fzaninotto/faker: ~1.4
- mockery/mockery: ~1.0
- orchestra/testbench: ~3.0
- phpunit/phpunit: ^6.0 || ^7.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-11-13 11:26:04 UTC
README
A service provider for laravel with a fluent elasticsearch mapping builder.
Supported laravel versions
Supported elasticsearch versions
Installation
Composer
composer require triadev/laravel-elasticsearch-mapping
Application
The package is registered through the package discovery of laravel and Composer.
Configuration
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.
Usage
This package offers a fluent mapping builder for elasticsearch. The entry point for each mapping build is a facade.
Triadev\Es\Mapping\Facade\ElasticMapping
Build mapping
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);
Create index
If the index does not exist a new index will be created. This also includes the configuration from $blueprint->settings().
Update index
If the index exists an update will be executed.
Reporting Issues
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. :)
Testing
- docker-compose -f docker-compose.yml up
- composer test
Contributing
Please see CONTRIBUTING for details.
Credits
Other
Project related links
License
The code for laravel-elasticsearch-mapping is distributed under the terms of the MIT license (see LICENSE).