Steps to install laravel/scout on Lumen framework (there are some additional steps that you need to do to make it work with lumen opposed to Laravel)
First install laravel
composer require laravel/scout
Register the service provider in the bootstrap/app.php in the provider section
$app->register(Laravel\Scout\ScoutServiceProvider::class);
Copy the configuration file (you may be able to do it with composer php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
, I wasn't)
cp vendor/laravel/scout/config/scout.php config/scout.php
Ask lumen to load the configuration file, adding this line to boostrap/app.php
$app->configure('scout');
Install laravel mysql mysql driver
composer require yab/laravel-scout-mysql-driver
Change the driver setting in config/scout.php
'driver' => env('SCOUT_DRIVER', 'mysql'),
Append this to config/scout.php
'mysql' => [
'mode' => 'NATURAL_LANGUAGE',
'model_directories' => [app_path()],
'min_search_length' => 0,
'min_fulltext_search_length' => 4,
'min_fulltext_search_fallback' => 'LIKE',
'query_expansion' => false
]
run the scout index if plan to use in NATURAL_LANGUAGE or BOOLEAN
php artisan scout:mysql-index
Use like this
Model::search(searchString)->get();
You can also add other conditions
Model::search(searchString)->where(...)->get()