Disclaimer: This project was highly inspired in ErickTamayo implementation. However it is not a fork and most likely is incompatible.
This package is intented to be used with laravel 5.6 and up. Others versions might work but might
composer require cfpinto/laravel-scout-elasticsearch
If your project doesn't have auto discovery you will need to add the providers manually in your app.php config file
'providers' => [
...
Laravel\Scout\ScoutServiceProvider::class,
...
ScoutEngines\Elasticsearch\ElasticsearchProvider::class
],
You must have an Elasticsearch instance running with the necessary index.
Change the config/scout.php file to include elasticsearch settings
// config/scout.php
// Set your driver to elasticsearch
'driver' => env('SCOUT_DRIVER', 'elasticsearch'),
...
'elasticsearch' => [
'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
'hosts' => [
env('ELASTICSEARCH_HOST', 'http://localhost'),
],
],
...
The driver will work just like described in laravel scout documentation.
If you want the ability to use closures in where and orWhere methods your model must use the Searchable trait included in the package
<?php
namespace App;
use ScoutEngines\Elasticsearch\Traits\Searchable;
class Product extends Model
{
use Searchable;
}
Hey dude! Help me out for a couple of 🍻!