PHPackages                             babenkoivan/elastic-scout-driver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. babenkoivan/elastic-scout-driver

ActiveLibrary[Search &amp; Filtering](/categories/search)

babenkoivan/elastic-scout-driver
================================

Elasticsearch driver for Laravel Scout

v6.0.0(1mo ago)2773.8M—3.1%364MITPHPPHP ^8.3CI passing

Since May 1Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/babenkoivan/elastic-scout-driver)[ Packagist](https://packagist.org/packages/babenkoivan/elastic-scout-driver)[ Fund](https://ko-fi.com/ivanbabenko)[ Fund](https://paypal.me/babenkoi)[ RSS](/packages/babenkoivan-elastic-scout-driver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (20)Used By (4)

 [![](logo.gif)](logo.gif)

 [![](https://camo.githubusercontent.com/998e228d22e8dba361a8663bf0b2364f344d2c27336448800d143df0a2b164af/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d73636f75742d6472697665722f762f737461626c65)](https://packagist.org/packages/babenkoivan/elastic-scout-driver) [![](https://camo.githubusercontent.com/a91e399c80ebdff03f8a7020cb27aae9326a06910cbd4753071aea360d31b41c/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d73636f75742d6472697665722f646f776e6c6f616473)](https://packagist.org/packages/babenkoivan/elastic-scout-driver) [![](https://camo.githubusercontent.com/32cc3739859c2b91514a056731728c61f86b0d4f50fc5429eb86930f485ad7d3/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d73636f75742d6472697665722f6c6963656e7365)](https://packagist.org/packages/babenkoivan/elastic-scout-driver) [![](https://github.com/babenkoivan/elastic-scout-driver-plus/workflows/Tests/badge.svg)](https://github.com/babenkoivan/elastic-scout-driver-plus/actions?query=workflow%3ATests) [![](https://github.com/babenkoivan/elastic-scout-driver/workflows/Code%20style/badge.svg)](https://github.com/babenkoivan/elastic-scout-driver/actions?query=workflow%3A%22Code+style%22) [![](https://github.com/babenkoivan/elastic-scout-driver/workflows/Static%20analysis/badge.svg)](https://github.com/babenkoivan/elastic-scout-driver/actions?query=workflow%3A%22Static+analysis%22) [![](https://camo.githubusercontent.com/0b8a275d67dfb2aa74ac299fa07b7fce95217f6620448d88cf05ff9e3653e9bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d70617970616c2d626c7565)](https://paypal.me/babenkoi)

 [![Support the project!](https://camo.githubusercontent.com/201ef269611db7eb6b5d08e9f756ab8980df3014b64492770bdf13a6ed924641/68747470733a2f2f6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/ivanbabenko)

---

Elasticsearch driver for Laravel Scout.

Contents
--------

[](#contents)

- [Compatibility](#compatibility)
- [Installation](#installation)
- [Configuration](#configuration)
- [Basic Usage](#basic-usage)
- [Advanced Search](#advanced-search)
- [Migrations](#migrations)
- [Pitfalls](#pitfalls)

Compatibility
-------------

[](#compatibility)

The current version of Elastic Scout Driver has been tested with the following configuration:

- PHP 8.3
- Elasticsearch 9.x
- Laravel 13.x
- Laravel Scout 11.x

If your project uses older Elasticsearch, Laravel, or PHP version check [the previous major version](https://github.com/babenkoivan/elastic-scout-driver/tree/v4.0.0#compatibility) of the package.

Installation
------------

[](#installation)

The library can be installed via Composer:

```
composer require babenkoivan/elastic-scout-driver
```

**Note**, that this library is just a driver for Laravel Scout, don't forget to install it beforehand:

```
composer require laravel/scout
```

After Scout has been installed, publish its configuration file using:

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

Then, change the `driver` option in the `config/scout.php` file to `elastic`:

```
// config/scout.php

'driver' => env('SCOUT_DRIVER', 'elastic'),
```

If you want to use Elastic Scout Driver with [Lumen framework](https://lumen.laravel.com/) check [this guide](https://github.com/babenkoivan/elastic-scout-driver/wiki/Lumen-Installation).

Configuration
-------------

[](#configuration)

Elastic Scout Driver uses [babenkoivan/elastic-client](https://github.com/babenkoivan/elastic-client) as a dependency. To change the client settings you need to publish the configuration file first:

```
php artisan vendor:publish --provider="Elastic\Client\ServiceProvider"
```

In the newly created `config/elastic.client.php` file you can define the default connection name using configuration hashes. Please, refer to the [elastic-client documentation](https://github.com/babenkoivan/elastic-client) for more details.

Elastic Scout Driver itself has only one configuration option at the moment - `refresh_documents`. If it's set to `true` (`false` by default) documents are indexed immediately, which might be handy for testing.

You can configure `refresh_documents` in the `config/elastic.scout_driver.php` file after publishing it with the following command:

```
php artisan vendor:publish --provider="Elastic\ScoutDriver\ServiceProvider"
```

At last, do not forget, that with Scout you can configure the searchable data, the model id and the index name. Check [the official Scout documentation](https://laravel.com/docs/master/scout#configuration) for more details.

> Note, that the `_id` field can't be part of the searchable data, so make sure the field is excluded or renamed in the `toSearchableArray` method in case you are using MongoDB as the database.

Basic usage
-----------

[](#basic-usage)

Elastic driver uses Elasticsearch [query string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html)wrapped in a [bool query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)under the hood. It means that you can use [mini-language syntax](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax)when searching a model:

```
$orders = App\Order::search('title:(Star OR Trek)')->get();
```

When the query string is omitted, the [match all query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html)is used:

```
$orders = App\Order::search()->where('user_id', 1)->get();
```

Please refer to [the official Laravel Scout documentation](https://laravel.com/docs/master/scout)for more details and usage examples.

Advanced Search
---------------

[](#advanced-search)

In case the basic search doesn't cover your project needs check [Elastic Scout Driver Plus](https://github.com/babenkoivan/elastic-scout-driver-plus), which extends standard Scout search capabilities by introducing advanced query builders. These builders give you possibility to use compound queries, custom filters and sorting, highlights and more.

Migrations
----------

[](#migrations)

If you are looking for a way to control Elasticsearch index schema programmatically check [Elastic Migrations](https://github.com/babenkoivan/elastic-migrations). Elastic Migrations allow you to modify application's index schema and share it across multiple environments with the same ease, that gives you Laravel database migrations.

Pitfalls
--------

[](#pitfalls)

There are few things, which are slightly different from other Scout drivers:

- As you probably know, Scout only indexes fields, which are returned by the `toSearchableArray` method. Elastic driver indexes a model even when `toSearchableArray` returns an empty array. You can change this behaviour by overwriting the `shouldBeSearchable` method of your model:

```
public function shouldBeSearchable()
{
    return count($this->toSearchableArray()) > 0;
}
```

- Raw search returns an instance of `SearchResult` class (see [Elastic Adapter](https://github.com/babenkoivan/elastic-adapter#search)):

```
$searchResult = App\Order::search('Star Trek')->raw();
```

- To be compatible with other drivers and to not expose internal implementation of the engine, Elastic driver ignores callback parameter of the `search` method:

```
App\Order::search('Star Trek', function () {
    // this will not be triggered
})->get()
```

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity62

Solid adoption and visibility

Community26

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 96.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~119 days

Recently: every ~279 days

Total

19

Last Release

56d ago

Major Versions

v1.6.0 → v2.0.02021-10-05

v2.0.0 → v3.0.02022-07-27

v3.2.0 → v4.0.02024-06-18

v4.0.0 → v5.0.02025-11-16

v5.0.0 → v6.0.02026-03-23

PHP version history (6 changes)v1.0.1PHP ^7.2

v1.3.0PHP ^7.2 || ^8.0

v2.0.0PHP ^7.3 || ^8.0

v3.0.0PHP ^7.4 || ^8.0

v4.0.0PHP ^8.2

v6.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25812954?v=4)[Ivan Babenko](/maintainers/babenkoivan)[@babenkoivan](https://github.com/babenkoivan)

---

Top Contributors

[![babenkoivan](https://avatars.githubusercontent.com/u/25812954?v=4)](https://github.com/babenkoivan "babenkoivan (115 commits)")[![Aniket-IN](https://avatars.githubusercontent.com/u/64463116?v=4)](https://github.com/Aniket-IN "Aniket-IN (1 commits)")[![spiritinlife](https://avatars.githubusercontent.com/u/6434983?v=4)](https://github.com/spiritinlife "spiritinlife (1 commits)")[![stevebauman](https://avatars.githubusercontent.com/u/6421846?v=4)](https://github.com/stevebauman "stevebauman (1 commits)")[![wbridgett](https://avatars.githubusercontent.com/u/7139214?v=4)](https://github.com/wbridgett "wbridgett (1 commits)")

---

Tags

driverelasticelasticsearchlaravelphpscoutphplaravelelasticsearchelasticdriverscout

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/babenkoivan-elastic-scout-driver/health.svg)

```
[![Health](https://phpackages.com/badges/babenkoivan-elastic-scout-driver/health.svg)](https://phpackages.com/packages/babenkoivan-elastic-scout-driver)
```

###  Alternatives

[babenkoivan/elastic-scout-driver-plus

Extension for Elastic Scout Driver

2862.8M1](/packages/babenkoivan-elastic-scout-driver-plus)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
