Package

Babenkoivan Elastic Scout Driver

Elasticsearch driver for Laravel Scout

Package

babenkoivan/elastic-scout-driver

View on GitHub →

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-client for setting up Elasticsearch client configurations. Also allows immediate document indexing with the refresh_documents configuration.
  • 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 toSearchableArray returns an empty array, with customizable behavior.

Installation and Setup:

  1. Install via Composer:

    composer require babenkoivan/elastic-scout-driver
    composer require laravel/scout
    
  2. Publish and configure Scout settings:

    php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
    

    Set the driver option in config/scout.php to elastic.

  3. 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 shouldBeSearchable and 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.

Babenkoivan Elastic Scout Driver Related Articles

Building fast, fuzzy site search with Laravel and Typesense image

Building fast, fuzzy site search with Laravel and Typesense

Read article

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

Pushsilver

Pushsilver is simple invoicing for freelancers and small studios — send polished invoices, automate reminders, and get paid on time without the bloat.

Pushsilver

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift