PHPackages                             aman-rawat/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. aman-rawat/elastic-scout-driver

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

aman-rawat/elastic-scout-driver
===============================

Elasticsearch driver for Laravel Scout

015[1 PRs](https://github.com/aman-rawat/elastic-scout-driver/pulls)PHP

Since Aug 1Pushed 1y agoCompare

[ Source](https://github.com/aman-rawat/elastic-scout-driver)[ Packagist](https://packagist.org/packages/aman-rawat/elastic-scout-driver)[ RSS](/packages/aman-rawat-elastic-scout-driver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [![](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 7.3-8.0
- Elasticsearch 7.x
- Laravel 6.x-8.x
- Laravel Scout 7.x-9.x

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. If you want to change the default client settings (and I'm pretty sure you do), then you need to create the configuration file first:

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

You can change Elasticsearch host and the other client settings in the `config/elastic.client.php` file. Please refer to [babenkoivan/elastic-client](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="ElasticScoutDriver\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 `SearchResponse` class (see [Elastic Adapter](https://github.com/babenkoivan/elastic-adapter#search)):

```
$searchResponse = 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

18

—

LowBetter than 8% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 93.1% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1590ae0f585833562a4c7cafd40cf0739ed06c88ebcbda18a9321bca943fe96?d=identicon)[aman-rawat](/maintainers/aman-rawat)

---

Top Contributors

[![babenkoivan](https://avatars.githubusercontent.com/u/25812954?v=4)](https://github.com/babenkoivan "babenkoivan (95 commits)")[![aman-rawat](https://avatars.githubusercontent.com/u/6269995?v=4)](https://github.com/aman-rawat "aman-rawat (4 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)")

### Embed Badge

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

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

###  Alternatives

[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)[handcraftedinthealps/zendsearch

a general purpose text search engine written entirely in PHP 5

39921.0k35](/packages/handcraftedinthealps-zendsearch)

PHPackages © 2026

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