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

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

jackardios/es-scout-driver
==========================

Advanced Elasticsearch driver for Laravel Scout with full Query DSL support

0266PHPCI passing

Since Feb 16Pushed 2mo agoCompare

[ Source](https://github.com/Jackardios/es-scout-driver)[ Packagist](https://packagist.org/packages/jackardios/es-scout-driver)[ RSS](/packages/jackardios-es-scout-driver/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

ES Scout Driver
===============

[](#es-scout-driver)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a06e14af5511404a8205a4b7afe18c0ded10c6e4daefb910a229cd0d40e27e67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61636b617264696f732f65732d73636f75742d6472697665722e737667)](https://packagist.org/packages/jackardios/es-scout-driver)
[![PHP Version](https://camo.githubusercontent.com/f3c9346cbbfee95450c50b84dee429bebcb30eb1379ea0d63d27e0d9a7062a93/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a61636b617264696f732f65732d73636f75742d6472697665722e737667)](https://packagist.org/packages/jackardios/es-scout-driver)
[![CI](https://github.com/jackardios/es-scout-driver/actions/workflows/ci.yml/badge.svg)](https://github.com/jackardios/es-scout-driver/actions)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://opensource.org/licenses/MIT)

Advanced Elasticsearch driver for Laravel Scout with full Query DSL support.

Features
--------

[](#features)

- Full Elasticsearch Query DSL support
- Fluent API for building complex queries
- Bool queries with `must`, `should`, `filter`, `mustNot`
- Full-text queries: `match`, `multi_match`, `match_phrase`, `query_string`
- Term-level queries: `term`, `terms`, `range`, `exists`, `prefix`, `wildcard`, `regexp`, `fuzzy`, `ids`
- Geo queries: `geo_distance`, `geo_bounding_box`, `geo_shape`
- Compound queries: `bool`, `nested`, `function_score`, `dis_max`, `boosting`, `constant_score`
- Joining queries: `has_child`, `has_parent`, `parent_id`
- Aggregations: `terms`, `avg`, `sum`, `min`, `max`, `stats`, `cardinality`, `histogram`, `date_histogram`, `range`
- Sorting with multiple options
- Highlighting
- Suggestions
- Pagination with cursor support
- Multi-index search
- Soft deletes support

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, or 12
- Elasticsearch 8.x or 9.x

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

[](#installation)

```
composer require jackardios/es-scout-driver
```

Publish the configuration files:

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

Configure your Elasticsearch connection in `.env`:

```
SCOUT_DRIVER=elastic

ELASTIC_HOST=localhost:9200
```

Quick Start
-----------

[](#quick-start)

### 1. Add the Searchable trait to your model

[](#1-add-the-searchable-trait-to-your-model)

```
use Jackardios\EsScoutDriver\Searchable;

class Book extends Model
{
    use Searchable;

    public function toSearchableArray(): array
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'author' => $this->author,
            'price' => $this->price,
            'published_at' => $this->published_at,
        ];
    }
}
```

### 2. Create your index (optional but recommended)

[](#2-create-your-index-optional-but-recommended)

For index management, we recommend [babenkoivan/elastic-migrations](https://github.com/babenkoivan/elastic-migrations):

```
composer require babenkoivan/elastic-migrations
php artisan elastic:make:migration create_books_index
php artisan elastic:migrate
```

> **Note:** The `config/elastic.client.php` is compatible with elastic-migrations.

### 3. Index your data

[](#3-index-your-data)

```
php artisan scout:import "App\Models\Book"
```

### 4. Search

[](#4-search)

```
use Jackardios\EsScoutDriver\Support\Query;

// Simple search
$books = Book::searchQuery(Query::match('title', 'laravel'))->execute();

// Complex search with bool query
$books = Book::searchQuery()
    ->must(Query::match('title', 'laravel'))
    ->filter(Query::term('status', 'published'))
    ->filter(Query::range('price')->gte(10)->lte(50))
    ->sort('published_at', 'desc')
    ->size(20)
    ->execute();

// Get models
$models = $books->models();

// Get total count
$total = $books->total;
```

Basic Usage
-----------

[](#basic-usage)

### Match Query

[](#match-query)

```
Book::searchQuery(Query::match('title', 'elasticsearch'))->execute();

// With options
Book::searchQuery(
    Query::match('title', 'elasticsearch')
        ->fuzziness('AUTO')
        ->operator('and')
)->execute();
```

### Multi-Match Query

[](#multi-match-query)

```
Book::searchQuery(
    Query::multiMatch(['title', 'description'], 'search text')
        ->type('best_fields')
        ->fuzziness('AUTO')
)->execute();
```

### Bool Query

[](#bool-query)

```
Book::searchQuery()
    ->must(Query::match('title', 'laravel'))
    ->must(Query::match('description', 'framework'))
    ->should(Query::term('featured', true))
    ->filter(Query::range('price')->lte(100))
    ->mustNot(Query::term('status', 'draft'))
    ->execute();
```

### Range Query

[](#range-query)

```
Book::searchQuery(
    Query::range('price')->gte(10)->lte(50)
)->execute();

// Date range
Book::searchQuery(
    Query::range('published_at')
        ->gte('2024-01-01')
        ->lte('now')
        ->format('yyyy-MM-dd')
)->execute();
```

### Sorting

[](#sorting)

```
use Jackardios\EsScoutDriver\Sort\Sort;

Book::searchQuery(Query::matchAll())
    ->sort('price', 'asc')
    ->sort('_score', 'desc')
    ->execute();

// Advanced sorting
Book::searchQuery(Query::matchAll())
    ->sort(Sort::field('price')->desc()->missing('_last'))
    ->sort(Sort::score())
    ->execute();
```

### Pagination

[](#pagination)

```
// Standard pagination
$paginator = Book::searchQuery(Query::matchAll())
    ->paginate(perPage: 15, pageName: 'page', page: 1);

// Access in Blade
@foreach ($paginator->models() as $book)
    {{ $book->title }}
@endforeach

{{ $paginator->links() }}
```

`perPage` must be greater than `0`, and `page` must be greater than or equal to `1`.

### Aggregations

[](#aggregations)

```
use Jackardios\EsScoutDriver\Aggregations\Agg;

$result = Book::searchQuery(Query::matchAll())
    ->aggregate('avg_price', Agg::avg('price'))
    ->aggregate('by_author', Agg::terms('author')->size(10))
    ->execute();

// Get aggregation results
$avgPrice = $result->aggregationValue('avg_price');
$authorBuckets = $result->buckets('by_author');
```

### Highlighting

[](#highlighting)

```
$result = Book::searchQuery(Query::match('title', 'laravel'))
    ->highlight('title', preTags: [''], postTags: [''])
    ->highlight('description')
    ->execute();

foreach ($result->hits() as $hit) {
    $highlights = $hit->highlight; // ['title' => ['Laravel Guide']]
}
```

Documentation
-------------

[](#documentation)

- [Search Builder](docs/search-builder.md) - Main search API
- [Queries](docs/queries.md) - All query types
- [Aggregations](docs/aggregations.md) - Aggregation types
- [Sorting](docs/sorting.md) - Sorting options
- [Search Results](docs/search-results.md) - Working with results
- [Configuration](docs/configuration.md) - Configuration options
- [Compatibility](docs/compatibility.md) - ES 8.x/9.x version notes

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance59

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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/d502bd9c7502e3464a661326548cb3698cf0a5dfc25b45fc4b93ee22fd1a23d2?d=identicon)[jackardios](/maintainers/jackardios)

---

Top Contributors

[![Jackardios](https://avatars.githubusercontent.com/u/24757335?v=4)](https://github.com/Jackardios "Jackardios (48 commits)")

---

Tags

driverelasticsearchfull-text-searchlaravelphpscout

### Embed Badge

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

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

###  Alternatives

[ruflin/elastica

Elasticsearch Client

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

PHP Client for OpenSearch

15024.3M64](/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)[shyim/opensearch-php-dsl

OpenSearch/Elasticsearch DSL library

175.9M9](/packages/shyim-opensearch-php-dsl)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

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

PHPackages © 2026

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