boxed-code / laravel-scout-elasticsearch
Elasticsearch Driver for Laravel Scout
Installs: 10 277
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|^8.0
- elasticsearch/elasticsearch: ^6.8|^7.0
- laravel/scout: ^8.0|^9.0
Requires (Dev)
- mockery/mockery: ~1.3.3
- phpunit/phpunit: ^8.0|^9.3
Suggests
- elasticsearch/elasticsearch: Required to use, the Elasticsearch engine (^5.0).
README
A basic elastic search backed driver for Laravel Scout.
This driver has a simple configuration, requiring you to set the hostname of your elasticsearch node.
Note that this driver uses a separate index for each model type as elasticsearch mapping types have been deprecated in elasticsearch 6.0 and will be removed in 8.0, for more information see https://bit.ly/2TZVZvq.
By default, the driver uses the simple_query_string
full text parser with and
as the default operator. More information on the functionality & syntax of this query format can be found here.
Requires Scout ^8.0 or ^9.0 & PHP >=7.2. Based on the original work of ErickTamayo (Scout 5/6/7 & elastic search server 5.x are supported by versions of 1.x)
Contents
Installation
You can install the package via composer:
composer require boxed-code/laravel-scout-elasticsearch
If you're using Laravel 5.4, you must add the Scout service provider and the package service provider in your app.php config:
// config/app.php 'providers' => [ ... Laravel\Scout\ScoutServiceProvider::class, ... ScoutEngines\Elasticsearch\ElasticsearchProvider::class, ],
Add the elastic search configuration
Add the following to your scout configuration:
// config/scout.php // Set your driver to elasticsearch 'driver' => env('SCOUT_DRIVER', 'elasticsearch'), ... 'elasticsearch' => [ 'debug' => false, 'hosts' => [ env('ELASTICSEARCH_HOST', 'http://localhost'), ], ], ...
Upgrading from 1.x -> 2.x
If you are upgrading from 1.x -> 2.x and are using an elastic server version < 7.x you will need to constrain the version of the base elastic driver used in your composer.json. For example if you're running 6.x:
composer require elasticsearch/elasticsearch:^6.0
** Remember: When you upgrade your server version to 7.x you will need to remove the package or upgrade it to the 7.x driver. **
Usage
Now you can use Laravel Scout as described in the official documentation
Credits
License
The MIT License (MIT).