Integrate Elastic App Search with Laravel Scout.
This is an early but functional version. Tests to be added.
You can install the package via composer:
composer require konsulting/scout-elastic-app-search
In order to use the package, you must set Laravel Scout to use the driver
SCOUT_DRIVER=elastic-app-search
Then set up the connection details for Elastic App Search
SCOUT_ELASTIC_APP_SEARCH_ENDPOINT=
SCOUT_ELASTIC_APP_SEARCH_API_KEY=
You will also need to adjust config/scout.php
so that the chunk sizes are 100 records:
'chunk' => [
'searchable' => 100,
'unsearchable' => 100,
],
Once you have adde the Searchable Trait to your model. You will be able to search with:
$result = Model::search($searchTerm)->get();
If you wish to have more control over the search, you can extend it in the familiar way with Scout.
$result = Model::search($searchTerm, function (ElasticAppProxy $elastic, $query, $options) {
// Adjust the options here
// E.g. set the search fields in options, and add weightings
$options['search_fields']['field_name']['weight'] = 1;
// Use filters, and so on
$options['filters'] = [
'all' => [
'name' => 'Konsulting',
'keyword' => 'Scout',
],
];
// Manipulate the position in results
$options['page']['size'] = $this->limit;
$options['page']['current'] = $this->currentPage();
return $elastic->search($query, $options);
})->get();
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.