Elastic Scout Driver
Elastic Scout Driver stats
- Downloads
- 1.4M
- Stars
- 223
- Open Issues
- 0
- Forks
- 29
Elasticsearch driver for Laravel Scout
Elastic Scout Driver for Laravel Scout
The Elastic Scout Driver is a Laravel package designed to integrate Elasticsearch with Laravel Scout, enhancing your Laravel application with powerful search capabilities.
Key Features:
- Compatibility with Multiple Versions: Supports PHP 7.4-8.x, Elasticsearch 8.x, Laravel 7.x-10.x, and Laravel Scout 7.x-10.x.
- Simple Installation: Easily installable via Composer and requires Laravel Scout to be set up first.
- Flexible Configuration: Utilizes
babenkoivan/elastic-clientfor setting up Elasticsearch client configurations. Also allows immediate document indexing with therefresh_documentsconfiguration. - Basic to Advanced Usage: Supports basic search functionalities using Elasticsearch query strings and offers advanced search capabilities through the Elastic Scout Driver Plus extension.
- Elasticsearch Migrations Support: Similar to Laravel's database migrations, Elastic Migrations help manage Elasticsearch index schema changes across environments.
- Unique Handling of Searchable Data: Unlike other Scout drivers, the Elastic driver indexes models even if
toSearchableArrayreturns an empty array, with customizable behavior.
Installation and Setup:
-
Install via Composer:
composer require babenkoivan/elastic-scout-drivercomposer require laravel/scout -
Publish and configure Scout settings:
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"Set the
driveroption inconfig/scout.phptoelastic. -
Publish and adjust client configuration as needed:
php artisan vendor:publish --provider="Elastic\Client\ServiceProvider"
Usage:
- Perform searches using a mini-language syntax or a match-all query:
$orders = App\Order::search('title:(Star OR Trek)')->get();$orders = App\Order::search()->where('user_id', 1)->get();
- For advanced search functionalities, consider using Elastic Scout Driver Plus for features like compound queries and custom filters.
Notes:
- Be aware of the unique behavior in indexing and searching, especially regarding the handling of
shouldBeSearchableand raw search results. - For Lumen users, specific installation instructions are provided in the package documentation.
This package extends Laravel Scout's capabilities, allowing for full-text search and more complex search queries using Elasticsearch, making it an essential tool for applications requiring efficient searching mechanisms.