PHPackages                             jackardios/elastic-scout-driver-plus - 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. jackardios/elastic-scout-driver-plus

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

jackardios/elastic-scout-driver-plus
====================================

Extension for Elastic Scout Driver

v4.0.1(2y ago)05371MITPHPPHP ^7.4 || ^8.0

Since May 1Pushed 2y agoCompare

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

READMEChangelog (9)Dependencies (9)Versions (45)Used By (1)

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

 [![](https://camo.githubusercontent.com/263289ec9c62e26dc3d161e1e7472c006452b7e249d8c86f96a26ff67669948e/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d73636f75742d6472697665722d706c75732f762f737461626c65)](https://packagist.org/packages/babenkoivan/elastic-scout-driver-plus) [![](https://camo.githubusercontent.com/f8b9250b2611381d1256577ea9b0056baa65665e2418b48ffd9f5ed51466759e/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d73636f75742d6472697665722d706c75732f646f776e6c6f616473)](https://packagist.org/packages/babenkoivan/elastic-scout-driver-plus) [![](https://camo.githubusercontent.com/1b43b970761b1a9d9d3048ceb17485944ebf59008b0b58f25c9cb5a6e2e3ad0a/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d73636f75742d6472697665722d706c75732f6c6963656e7365)](https://packagist.org/packages/babenkoivan/elastic-scout-driver-plus) [![](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-plus/workflows/Code%20style/badge.svg)](https://github.com/babenkoivan/elastic-scout-driver-plus/actions?query=workflow%3A%22Code+style%22) [![](https://github.com/babenkoivan/elastic-scout-driver-plus/workflows/Static%20analysis/badge.svg)](https://github.com/babenkoivan/elastic-scout-driver-plus/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)

---

Extension for [Elastic Scout Driver](https://github.com/babenkoivan/elastic-scout-driver).

Contents
--------

[](#contents)

- [Features](#features)
- [Compatibility](#compatibility)
- [Installation](#installation)
- [Usage](#usage)
    - [Query](#query)
    - [Search parameters](#search-parameters)
    - [Search results](#search-results)
    - [Custom routing](#custom-routing)
    - [Eager loading relations](#eager-loading-relations)
    - [Multiple connections](#multiple-connections)

Features
--------

[](#features)

Elastic Scout Driver Plus supports:

- [Aggregations](docs/available-methods.md#aggregate)
- [Custom routing](#custom-routing)
- [Highlighting](docs/available-methods.md#highlight)
- [Multiple connections](#multiple-connections)
- [Search across multiple indices](docs/available-methods.md#join)
- [Search after](docs/available-methods.md#searchafter)
- [Source filtering](docs/available-methods.md#source)
- [Suggesters](docs/available-methods.md#suggest)

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

[](#compatibility)

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

- PHP 7.4-8.x
- Elasticsearch 8.x
- Laravel 7.x-10.x
- Laravel Scout 7.x-10.x

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

[](#installation)

The library can be installed via Composer:

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

**Note** that this library doesn't work without Elastic Scout Driver. If it's not installed yet, please follow the installation steps described [here](https://github.com/babenkoivan/elastic-scout-driver#installation). If you already use Elastic Scout Driver, I recommend you to update it before installing Elastic Scout Driver Plus:

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

After installing the libraries, you need to add `Elastic\ScoutDriverPlus\Searchable` trait to your models. In case some models already use the standard `Laravel\Scout\Searchable` trait, you should replace it with the one provided by Elastic Scout Driver Plus.

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

Usage
-----

[](#usage)

### Query

[](#query)

Before you begin searching a model, you should define a query. You can either use a query builder or describe the query with an array:

```
use Elastic\ScoutDriverPlus\Support\Query;

// using a query builder
$query = Query::match()
    ->field('title')
    ->query('My book')
    ->fuzziness('AUTO');

// using a raw query
$query = [
    'match' => [
        'title' => [
            'query' => 'My book',
            'fuzziness' => 'AUTO'
        ]
    ]
];
```

Each method of `Elastic\ScoutDriverPlus\Support\Query` factory creates a query builder for the respective type. Available methods are listed below:

- [bool](docs/compound-queries.md#boolean)
- [exists](docs/term-queries.md#exists)
- [fuzzy](docs/term-queries.md#fuzzy)
- [geoDistance](docs/geo-queries.md#geo-distance)
- [ids](docs/term-queries.md#ids)
- [matchAll](docs/full-text-queries.md#match-all)
- [matchNone](docs/full-text-queries.md#match-none)
- [matchPhrasePrefix](docs/full-text-queries.md#match-phrase-prefix)
- [matchPhrase](docs/full-text-queries.md#match-phrase)
- [match](docs/full-text-queries.md#match)
- [multiMatch](docs/full-text-queries.md#multi-match)
- [nested](docs/joining-queries.md#nested)
- [prefix](docs/term-queries.md#prefix)
- [range](docs/term-queries.md#range)
- [regexp](docs/term-queries.md#regexp)
- [term](docs/term-queries.md#term)
- [terms](docs/term-queries.md#terms)
- [wildcard](docs/term-queries.md#wildcard)

### Search Parameters

[](#search-parameters)

When the query is defined, you can begin new search with `searchQuery` method:

```
$builder = Book::searchQuery($query);
```

You can then chain other parameters to make your search request more precise:

```
$builder = Book::searchQuery($query)
    ->size(2)
    ->sort('price', 'asc');
```

The builder supports various search parameters and provides a number of useful helpers:

- [aggregate](docs/available-methods.md#aggregate)
- [collapse](docs/available-methods.md#collapse)
- [explain](docs/available-methods.md#explain)
- [from](docs/available-methods.md#from)
- [highlight](docs/available-methods.md#highlight)
- [join](docs/available-methods.md#join)
- [load](docs/available-methods.md#load)
- [minScore](docs/available-methods.md#minscore)
- [postFilter](docs/available-methods.md#postfilter)
- [size](docs/available-methods.md#size)
- [sort](docs/available-methods.md#sort)
- [setEloquentQueryCallback](docs/available-methods.md#setEloquentQueryCallback)
- [rescore](docs/available-methods.md#rescore)
- [source](docs/available-methods.md#source)
- [suggest](docs/available-methods.md#suggest)
- [trackScores](docs/available-methods.md#trackscores)
- [trackTotalHits](docs/available-methods.md#tracktotalhits)
- [when](docs/available-methods.md#when)

### Search Results

[](#search-results)

You can retrieve search results by chaining the `execute` method onto the builder:

```
$searchResult = Book::searchQuery($query)->execute();
```

`$searchResult` provides easy access to matching hits, models, documents, etc.:

```
$hits = $searchResult->hits();
$models = $searchResult->models();
$documents = $searchResult->documents();
$highlights = $searchResult->highlights();
```

You can get more familiar with the `$searchResult` object and learn how to paginate the search results on [this page](docs/search-results.md).

### Custom Routing

[](#custom-routing)

If you want to use a [custom shard routing](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-routing-field.html)for your model, override the `searchableRouting` method:

```
class Book extends Model
{
    use Elastic\ScoutDriverPlus\Searchable;

    public function searchableRouting()
    {
        return $this->user->id;
    }
}
```

Custom routing is automatically applied to all index and delete operations.

### Eager Loading Relations

[](#eager-loading-relations)

Sometimes you need to index your model with related data:

```
class Book extends Model
{
    use Elastic\ScoutDriverPlus\Searchable;

    public function toSearchableArray()
    {
        return [
            'title' => $this->title,
            'price' => $this->price,
            'author' => $this->author->only(['name', 'phone_number']),
        ];
    }
}
```

You can improve the performance of bulk operations by overriding the `searchableWith` method:

```
class Book extends Model
{
    use Elastic\ScoutDriverPlus\Searchable;

    public function toSearchableArray()
    {
        return [
            'title' => $this->title,
            'price' => $this->price,
            'author' => $this->author->only(['name', 'phone_number']),
        ];
    }

    public function searchableWith()
    {
        return ['author'];
    }
}
```

In case you are looking for a way to preload relations for models matching a search query, check the builder's `load` method [documentation](docs/available-methods.md#load).

### Multiple Connections

[](#multiple-connections)

You can configure multiple connections to Elasticsearch in the [client's configuration file](https://github.com/babenkoivan/elastic-client/tree/master#configuration). If you want to change a connection used by a model, you need to override the `searchableConnection` method:

```
class Book extends Model
{
    use Elastic\ScoutDriverPlus\Searchable;

    public function searchableConnection(): ?string
    {
        return 'books';
    }
}
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 83.5% 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 ~34 days

Recently: every ~213 days

Total

41

Last Release

823d ago

Major Versions

v1.18.1 → v2.0.02021-03-01

v2.6.0 → v3.0.x-dev2021-10-05

v3.3.0 → v4.0.02024-01-30

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

v2.0.0PHP ^7.2 || ^8.0

v3.0.x-devPHP ^7.3 || ^8.0

v4.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d502bd9c7502e3464a661326548cb3698cf0a5dfc25b45fc4b93ee22fd1a23d2?d=identicon)[jackardios](/maintainers/jackardios)

---

Top Contributors

[![babenkoivan](https://avatars.githubusercontent.com/u/25812954?v=4)](https://github.com/babenkoivan "babenkoivan (237 commits)")[![Jackardios](https://avatars.githubusercontent.com/u/24757335?v=4)](https://github.com/Jackardios "Jackardios (28 commits)")[![spiritinlife](https://avatars.githubusercontent.com/u/6434983?v=4)](https://github.com/spiritinlife "spiritinlife (15 commits)")[![rmzindorf](https://avatars.githubusercontent.com/u/3467602?v=4)](https://github.com/rmzindorf "rmzindorf (1 commits)")[![marcintokarskipwn](https://avatars.githubusercontent.com/u/81288963?v=4)](https://github.com/marcintokarskipwn "marcintokarskipwn (1 commits)")[![Jonathanm10](https://avatars.githubusercontent.com/u/8361115?v=4)](https://github.com/Jonathanm10 "Jonathanm10 (1 commits)")[![petsoukos](https://avatars.githubusercontent.com/u/1178259?v=4)](https://github.com/petsoukos "petsoukos (1 commits)")

---

Tags

phplaravelelasticsearchelasticdriverscout

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[babenkoivan/elastic-scout-driver

Elasticsearch driver for Laravel Scout

2773.8M5](/packages/babenkoivan-elastic-scout-driver)[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)
