thucnc / laravel-scout-elasticsearch
Elasticsearch driver for Laravel Scout
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/thucnc/laravel-scout-elasticsearch
Requires
- php: >=7.0
- elasticsearch/elasticsearch: ^6.0
- laravel/scout: ^4.0
Requires (Dev)
- mockery/mockery: ~1.0
- phpunit/phpunit: ~6.0
This package is not auto-updated.
Last update: 2025-12-11 03:30:33 UTC
README
This package provides a Elasticsearch driver for Laravel Scout.
Installation
First, install Laravel Scout Elasticsearch via the Composer package manager:
composer require gtk/laravel-scout-elasticsearch
When using the Elasticsearch driver, you should configure your Elasticsearch hosts in your config/scout.php configuration file.
'elasticsearch' => [
'hosts' => [
env('ELASTICSEARCH_HOST', 'http://localhost:9200'),
],
],
Usage
Default usage can be found on the Laravel Scout documentation.
You may begin searching a model using the search method. The search method accepts a single string that will be used to search your models. You should then chain the get method onto the search query to retrieve the Eloquent models that match the given search query:
$orders = App\Order::search('Star Trek')->get();
In addition, the search method accepts an array that will be used as an Elasticsearch raw query to perform an advanced search:
$orders = App\Order::search([
'query' => [
'query_string' => [
'query' => 'Star Trek',
],
],
])->get();
You can check Elastic document for more information.
License
Laravel Scout Elasticsearch is open-sourced software licensed under the MIT license.