Download the PHP package pion/laravel-lelastico without Composer
On this page you can find all versions of the php package pion/laravel-lelastico. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-lelastico
Lelastico - easier elastic search for Laravel
Introduction
Focus of this library is to make it easier to manage elastic indices (wit mappings / settings), create reusable query building (manual or from request).
- Adds ability to manage elasticsearch indices with wrapper class which will help to you create/update index write documents (with bulk mode) etc.
- Adds ability to create a query builder with query filters for each index.
- Adds ability to build a query builder from request data (reusable component).
Requirements
- Composer
- PHP 7.4+
Installation
1. Add custom repository to composer.json
2. Install via composer
3. Add the service provider (Laravel 5.4 and below - supports Auto discovery)
Dependencies
- erichard/elasticsearch-query-builder - at this moment forked version with additional functions.
- elasticsearch/elasticsearch, version 7 and above (tested with 7.5).
Usage
Set elastic hosts
For development, you can use default value in the config without password: localhost:9200
Use ELASTICSEARCH_HOSTS environment for setting elastic search hosts. Format.
Resolve elastic search client
Mapping types constants
Property mappings types using constants like:
- MappingTypes::KEYWORD
- MappingTypes::TEXT
- MappingTypes::TEXT_WITH_KEYWORD
- MappingTypes::SHORT
- MappingTypes::SHORT_WITH_KEYWORD
- MappingTypes::LONG
- MappingTypes::LONG_WITH_KEYWORD
- MappingTypes::INTEGER
- MappingTypes::INTEGER_WITH_KEYWORD
- MappingTypes::DATE
- MappingTypes::BOOLEAN
- MappingTypes::FLOAT
- MappingTypes::textWithAnalyzer(string $analyzer, string $searchAnalyzer), builds
Adding indices
-
Create your indices by extending
AbstractElasticIndexand implementingcreateIndexNamefor elastic index-
Implement
propertyMappingsfor custom mappings. - Implement
settingsfor custom index settings
-
-
Create or update
lelastico.phpconfig with indices classes. - Update or create indices in elastic (stores settings / mapping) using
php artisan elastic:indices
Sorting
By default we are sorting by _id after any HasSorting logic to ensure that pagination is correct.
You can turn this feature by using $builder->setSortById(false);
To enable sortable behavior add HasSorting trait to your instance of AbstractBuilder and implement method allowedSortFields.
With sorting enabled you can sort the results using sort request query parameter. This parameter accepts list of fields for sorting in format {field_name}:{sort_direction}.
Available directions for sorting are asc and desc and if not specified the default sort direction is set to asc.
Examples:
sort[]=goals
sort[]=goals:asc&sort[]=minutes:desc
Configuration
log_measurementLogs every query to log (default false). You can useELASTICSEARCH_LOG_MEASUREMENTenv.log_debugDebug logs every query data to a log (true in local environment). You can useELASTICSEARCH_LOG_DEBUGenv.serviceEnables to change available indices (implement IndicesServiceContract or extend IndicesService)prefixUsed prefix for index names - uses APPNAME and replace '-' to '', converts name to slug variant.hostsA list of IPS for your elastic search - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/configuration.html. Use;separator. Default localhost:9200.
TODO
- improve documentation
- add
makeconsole.
Changelog
Can be found in releases.
Contribution or extending
See CONTRIBUTING.md for how to contribute changes. All contributions are welcome.
Sponsors
This library was created and improved thanks to clients projects.
Copyright and License
laravel-elastico was written by Martin Kluska and is released under the MIT License.
Copyright (c) 2020 Martin Kluska
All versions of laravel-lelastico with dependencies
illuminate/support Version >=5.5
illuminate/http Version >=5.5
illuminate/pagination Version >=5.5
illuminate/console Version >=5.5
illuminate/validation Version >=5.5
elasticsearch/elasticsearch Version ^7.17
erichard/elasticsearch-query-builder Version dev-collapse-and-improvments#9efe1b3a4491b8ca21b077d4d38ec8d53eeadd33