Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

cfpinto/laravel-scout-elasticsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Scout Elasticsearch Driver

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