Download the PHP package payamjafari/elasticute without Composer
On this page you can find all versions of the php package payamjafari/elasticute. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package elasticute
ElastiCute - A QueryBuilder for ElasticSearch
By using this builder you can easily make your database queries without writing raw queries.
Installation
Usage
Just call method "query" in QueryBuilder class and you are ready.
Filter query
For filtering your query you can use several methods such as where
, whereNot
, orWhere
, ...
.
Filter Methods
Name | Description |
---|---|
where(string $name, $value, string $operator, array $extra) |
Matches values that is not a specified value. |
whereNot(string $name, $value, string $operator, array $extra) |
Matches values that is a specified value. |
whereContains( string $name, $value ) |
Matches values that are contains a specified value. |
whereNotContains( string $name, $value ) |
Matches values that are not contains a specified value. |
whereEqual( string $name, $value ) |
Matches values that are equal to a specified value. |
whereNotEqual( string $name, $value ) |
Matches all values that are not equal to a specified value. |
whereExists( string $name ) |
Matches documents that have the specified field. |
whereNotExists( string $name ) |
Matches documents that dont have the specified field. |
Group Filter
You can set your filters as a group by just adding a closure to "where" method.
Group Filter Methods
Name | Description |
---|---|
groupShould( callable $filters ) |
See Official Documentation |
groupMust( callable $filters ) |
See Official Documentation |
groupMustNot( callable $filters ) |
See Official Documentation |
groupFilter( callable $filters ) |
See Official Documentation |
Aggregations
Aggregations are so important and could be used anywhere. So you can use it very easy. Take a look at the example.
Aggregation methods
Name | Description |
---|---|
avg() |
Aggregate based on 'avg' type |
terms() |
Aggregate based on 'terms' type |
histogram() |
Aggregate based on 'histogram' type |
max() |
Aggregate based on 'max' type |
min() |
Aggregate based on 'min' type |
Note: More aggregations will be added over time :)
Response
Each Request has a response, then it must be processed.
Response Methods
Name | Description |
---|---|
toArray() |
Returns as array. |
toJson() |
Returns as json. |
toList() |
Returns as array list (if its a search query). |
map() |
Map through the results(if its a search query) |
Sort / OrderBy
Paginate documents
Select specific fields
Select index at runtime
You can select your index at the query by calling "index" method.
Find by id
By calling method "find", you can retrieve the document based on id.
Get index mapping
By calling method "mapping", you can retrieve the index mapping.
Pro tip :)
You dont have to call "query" method first. you can directly call index right at the beginning.
All versions of elasticute with dependencies
vlucas/phpdotenv Version >=4.2.0
elasticsearch/elasticsearch Version >=6.8.2
ext-json Version *