Download the PHP package thaoha/eloquent-search without Composer
On this page you can find all versions of the php package thaoha/eloquent-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thaoha/eloquent-search
More information about thaoha/eloquent-search
Files in thaoha/eloquent-search
Package eloquent-search
Short Description Index Eloquent models to Elasticsearch
License MIT
Homepage https://github.com/thaoha/eloquent-search
Informations about the package eloquent-search
eloquent-search
Index Eloquent models to Elasticsearch. Eloquent-search use Official low-level client for Elasticsearch. You should read more about Elasticsearch at https://www.elastic.co to get basic knowledge.
Installation via Composer
The recommended method to install eloquent-search
is through Composer.
Once you've run a composer update
, you need to register Laravel service provider, in your config/app.php
:
Or with Lumen, you need add to bootstrap/app.php
:
And now you can add ElasticModelTrait
to any Eloquent model you want to index to Elasticsearch:
Config
Laravel 5:
Or you can copy config.php
file to your config folder and change the filename to elastic.php
. With Lumen you need add new config file to bootstrap/app
:
Index
Create index to store your data first. Use esCreateIndex()
function from you model class:
esCreateIndex()
function use property $esIndexMapping
in Company
model to set mapping settings. Elastic will auto detect if $esIndexMapping
empty:
If you want to update mapping settings you can use (use esReset()
function when conflict error):
Delete index:
Reset index. Just use this function (this function will delete all your index include your data and create new one with mapping settings):
Get and Index model
With each model object already use ElasticModelTrait
you can index to Elasticsearch with esIndex()
function:
With default it will be use $company->toArray()
to get data. Very easy to override with esSerialize()
function:
Delete model
Update model
a Model or a Collection you can do with same way.
Search
You should read more at https://www.elastic.co/ to build you params search