cfpinto/laravel-scout-elasticsearch

This package is abandoned and no longer maintained. The author suggests using the jeroen-g/explorer package instead.

Laravel scout driver for ElasticSearch

v1.0.6 2021-03-16 10:43 UTC

This package is auto-updated.

Last update: 2022-03-04 15:30:17 UTC


README

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

Installation

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
],

Setup Elasticsearch configuration

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'),
        ],
    ],
...

Usage

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; 
}

Credits

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay