Download the PHP package opsource/queryadapter without Composer
On this page you can find all versions of the php package opsource/queryadapter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download opsource/queryadapter
More information about opsource/queryadapter
Files in opsource/queryadapter
Package queryadapter
Short Description Revolutionize your Laravel query management with Laravel Query Adapter! Our adapter package includes multiple query executioners, including Elasticsearch and Eloquent, to help you efficiently run your Laravel queries. Say goodbye to query management headaches and hello to seamless query execution with Laravel Query Adapter. ies.
License MIT
Homepage https://github.com/vahidaghazadeh/queryadapter
Informations about the package queryadapter
Laravel Query Adapter search engines
Currently, you can use Elasticsearch and Redis, and we are developing other search engines
Installation
You can install the package via composer:
composer require ensi/laravel-elastic-queryEngine
- Set
ELASTICSEARCH_HOSTS
in your.env
file.,
can be used as a delimeter.
Basic usage
Let's create and index class. It's someting like Eloquent model.
You should set a unique in document attribute name in $indicator
. It is used as an additional sort in search_after
Now we can get some documents
Filtering
nested_field
must have nested
type.
Subqueries cannot use fields of main document only subdocument.
Full text search
field_one
and field_two
must be of text type. If no type is given, the MatchType::BEST_FIELDS
is used.
Sorting
Second attribute is a direction. It supports asc
and desc
values. Defaults to asc
.
Third attribute - sorting type. List of supporting types: min, max, avg, sum, median
. Defaults to min
.
There are also dedicated sort methods for each sort type.
Pagination
Offset Pagination
Offset pagination returns total documents count as total
and current position as size/offset
.
Cursor pagination
current
, next
, previous
is returned in this case instead of total
, size
and offset
.
You can check Laravel docs for more info about cursor pagination.
Aggregation
Aggregaction queries can be created like this
Type of $aggs->price
is MinMax
.
Type of $aggs->codes
is BucketCollection
.
Aggregate names must be unique for whole queryEngine.
Aggregate types
Get all variants of attribute values:
Get min and max attribute values. E.g for date:
Get count unique attribute values:
Aggregation plays nice with nested documents.
There is also a special virtual composite
aggregate on the root level. You can set special conditions using it.
Suggesting
Suggest queries can be created like this
Global suggest text
User can set global text like this
Suggester types
Term suggester:
Phrase Suggester:
Additional methods
Query Log
Just like Eloquent ElasticQuery has its own queryEngine log, but you need to enable it manually
Each message contains indexName
, queryEngine
and timestamp
Environment Variables
Below see the environment variables that you can configure with the default values,
Hosts should be comma seperated string of hosts with protocol prefix and port suffix, e.g. http://localhost:9200,http://localhost:9201
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
- npm i
- Start Elasticsearch in your preferred way.
- Copy
phpunit.xml.dist
tophpunit.xml
and set correct env variables there - 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 queryadapter with dependencies
elasticsearch/elasticsearch Version >=v8.1.0
opsource/rabbitmq Version >=1.0.2
symfony/http-client Version ^7.0
symfony/psr-http-message-bridge Version ^7.0