Download the PHP package ensi/laravel-elastic-query-specification without Composer
On this page you can find all versions of the php package ensi/laravel-elastic-query-specification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ensi/laravel-elastic-query-specification
More information about ensi/laravel-elastic-query-specification
Files in ensi/laravel-elastic-query-specification
Package laravel-elastic-query-specification
Short Description laravel elastic query specification
License MIT
Informations about the package laravel-elastic-query-specification
Laravel Elastic Query Specification
Extension for ensi/laravel-elastic-query to describe queries in a declarative way.
Installation
- Install ensi/laravel-elastic-query https://github.com/ensi-platform/laravel-elastic-query#installation
- Install this package via composer:
Version Compatibility
Laravel Elastic Query Specification | Laravel | PHP | Laravel Elastic Query |
---|---|---|---|
^0.1.0 | ^8.0 | ^8.0 | ^0.2.0 |
^0.2.0 | ^8.0 | ^8.0 | ^0.3.0 |
^0.2.3 | ^8.0 || ^9.0 | ^8.0 | ^0.3.0 |
^0.3.0 | ^8.0 || ^9.0 | ^8.0 | ^0.3.0 |
^7.x (see details) | ^9.0 || ^10.0 || ^11.0 | ^8.1 | ^7.1.0 |
^8.0.0 | ^8.0 || ^9.0 | ^8.0 | ^8.0 |
^8.0.2 | ^8.0 || ^9.0 || ^10.0 | ^8.0 | ^8.0 |
^8.0.3 | ^8.0 || ^9.0 || ^10.0 || ^11.0 | ^8.0 | ^8.0.23 |
^8.1.0 | ^9.0 || ^10.0 || ^11.0 | ^8.1 | ^8.1.0 |
Basic usage
All types of declarative queries are based on the specification. It contains definitions of available filters, sorts, and aggregates.
Here are examples of queries for this specification.
The nested
method adds specifications for nested documents. The names of filters, aggregates, and sorts are exported
from them to the global scope without adding any prefixes. It is acceptable to have the same names for filters, but not
for other components.
In the specifications for nested documents, only the fields of these documents can be used.
It is acceptable to add several specifications for the same nested
field.
The where*
constraints allow you to set additional program selection conditions that cannot be changed by the client.
The constraints specified in the root specification are always applied. Constraints in the nested specifications are
only used as additions to filters, aggregates, or sorts added to the query. For example, if there is no active filter
in the nested specification, then the constraints from this specification will not fall into the filters section
of the Elasticsearch query.
The allowedFilters
method determines the filters available to the client. Each filter must contain a unique name within
the specification. At the same time, in the root and nested specifications or in different nested specifications,
the names may be repeated. All filters with the same name will be filled with one value from the query parameters.
In addition to the name of the filter itself, you can separately specify the name of the field in the index for which it is applied, and the default value.
Types of filters
The sorts available to the client are added by the allowedSorts
method. The sorting direction is set in its name.
The sign +
or the absence of a sign corresponds to the ascending order, -
to the descending order.
By default, ascending sorting is used with the minimum selection, if there are several values in the field.
To sort from a nested specification, all constraints and active filters from the same specification are taken into account.
Aggregates are declared with the allowedAggregates
method. The client specifies in the query parameters a list of names
of aggregates, the results of which he expects in the response.
Types of aggregates
Aggregates from nested specifications are added to the Elasticsearch query with all constraints and active filters.
You can use the allowedFacets
method to define facets. Each facet requires an aggregate and one or
more filters. You can use both the existing aggregate
and the aggregate created by the facet itself
Filters are registered in the specification separately. Only their names are passed to facet creation methods.
During the calculation of the available values for each facet, all set filters are applied except those associated with this facet.
Search for documents
Calculation of summary indicators
Determining the available facet values
Elasticsearch 7 and 8 support.
Due to the incompatibility of clients for Elasticsearch 7 and 8, separate releases will be created for these versions. Development for each version is carried out in the corresponding branch.
To make changes to version 7, you need to create a task branch based on v7 and make a pull request to it. For version 8 it is similar, but based on the v8 branch.
Contributing
Please see CONTRIBUTING for details.
Testing
- composer install
- start Elasticsearch in your preferred way
- if you need change
ELASTICSEARCH_HOSTS
, copyphpunit.xml.dist
tophpunit.xml
and fill value - composer test
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-elastic-query-specification with dependencies
ensi/laravel-elastic-query Version ^8.1.0
laravel/framework Version ^9.0 || ^10.0 || ^11.0
webmozart/assert Version ^1.11