Download the PHP package tamizh/laravel-es without Composer
On this page you can find all versions of the php package tamizh/laravel-es. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-es
laravel-es
The basic orm package for elasticsearch (search and CRUD functionalities) - for elasticsearch 5.0 and lesser versions
Installation
composer require tamizh/laravel-es
or add the following line in composer.json line
"tamizh/laravel-es" : "dev-master" and run
Configuration
Add the service provider to your config/app.php file:
'providers' => [
//...
Tamizh\LaravelEs\ElasticsearchServiceProvider::class,
],
Add the facade to your config/app.php file:
'aliases' => [
//...
'Elasticsearch' => Tamizh\LaravelEs\Elasticsearch::class,
],
Publish config file using
Modifiy the config/elasticsearch.php.
Example
return [
'hosts' => [
env('ES_HOSTS', 'localhost:9200')
],
'log_path' => 'storage/logs/',
];
Instead of extends the Model class in your models extend the Elasticsearch to use the following functions.
class Log extends Elasticsearch
{
public $_index = 'logs*';
public $_type = 'log';
}
Available Functions
-
match & match_phrase - Returns the results that matches the text
-
boolMust, boolMustNot, boolShould, boolShouldNot - Boolean queries (Equal to AND and OR in mysql)
-
terms - Return the result that matches terms array
-
aggs - Aggregate the result (sub aggregation not yet supported)
Multiple aggregation can be achieved by
Sub Aggregation can be achieved by
available functions a) terms b) cardinality c) max d) min e) sum_bucket f) sum d) date_histogram (with interval option [default - month]) e) avg
-
sort - Sort the query result
or
- scroll - Get the Iterator Object to scroll.
-
size - Size of the result collection
-
highlight - To highlight the selected text
-
first - To get first model
-
save - To save the current model to the ES
-
delete - To delete the current model from ES
or
-
query_string - query string function in ES
in bool functions
-
exists - exists condition functionality
-
index - index document in ES
-
update - update document in ES
-
removeKey - remove unwanted key from ES
-
script - script functionality
-
count - get count of documents for current result
-
range - get the result set between a range
-
rangeBetween - get the result set between a range (Simplified version of range)
-
from - pagination option in elasticsearch [MySQL offset] [only applicable for 10000 result window, scroll is encouraged for bigger pagination]
-
paginate - pagination added [LengthAwarePaginator] Using this api will give you the complete function access of paginator in laravel
Note - This can be used in the space of first 10000 result set for the current query. So if you intend to use the whole result set, then the better option is to use the scroller.
-
search or searchRaw - To search by the raw array query
Note - For query format check the official documentation elasticsearch PHP package
-
topHits - to get the top hits of a aggregation
-
multiMatch - To search on multiple fields
-
fromType - To search on specific type
-
find - Find the document by its ID
- updateByQuery (experimental) - Update the documents using query (Not production ready)
Notes
- Following field names are reserved - _id, _type, _index, _highlight
TODO
- Write test cases (stable version)
- Adding More functionalities
- Indexing functionalities
- Mysql query format support