Elastic Scout Driver

babenkoivan/elastic-scout-driver image

Elastic Scout Driver stats

Downloads
1.4M
Stars
223
Open Issues
0
Forks
29

View on GitHub →

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-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.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


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
Shift logo

Shift

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

Shift
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media