PHPackages                             wonsulting/opensearch-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. wonsulting/opensearch-scout-driver-plus

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

wonsulting/opensearch-scout-driver-plus
=======================================

Extension for OpenSearch Scout Driver

2.1.1(3d ago)068—6.8%MITPHP ^7.4 || ^8.0

Since Oct 21Compare

[ Source](https://github.com/wonsulting/opensearch-scout-driver-plus)[ Packagist](https://packagist.org/packages/wonsulting/opensearch-scout-driver-plus)[ Fund](https://paypal.me/babenkoi)[ Fund](https://ko-fi.com/ivanbabenko)[ RSS](/packages/wonsulting-opensearch-scout-driver-plus/feed)WikiDiscussions Synced today

READMEChangelogDependencies (8)Versions (10)Used By (0)

OpenSearch Scout Driver Plus
============================

[](#opensearch-scout-driver-plus)

Extension for [OpenSearch Scout Driver](https://github.com/wonsulting/opensearch-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)

OpenSearch 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)
- [Source filtering](docs/available-methods.md#source)
- [Suggesters](docs/available-methods.md#suggest)

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

[](#compatibility)

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

- PHP 8.2+
- OpenSearch 2.x
- Laravel 11.x-13.x
- Laravel Scout 10.x-11.x

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

[](#installation)

The library can be installed via Composer:

```
composer require wonsulting/opensearch-scout-driver-plus
```

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

```
composer update wonsulting/opensearch-scout-driver
```

After installing the libraries, you need to add `OpenSearch\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 OpenSearch Scout Driver Plus.

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 OpenSearch\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 `OpenSearch\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)
- [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)
- [refineModels](docs/available-methods.md#refinemodels)
- [rescore](docs/available-methods.md#rescore)
- [refineModels](docs/available-methods.md#refinemodels)
- [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)
- [explain](docs/available-methods.md#explain)

### 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://opensearch.org/docs/opensearch/mappings/)for your model, override the `searchableRouting` method:

```
class Book extends Model
{
    use OpenSearch\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 OpenSearch\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 OpenSearch\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 OpenSearch in the [client's configuration file](https://github.com/wonsulting/opensearch-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 OpenSearch\ScoutDriverPlus\Searchable;

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

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance99

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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 ~338 days

Total

5

Last Release

3d ago

Major Versions

0.1.1 → 2.0.02023-04-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c764594a5302db666f3e72a34e32af56f198d210a8729e4a9901881d8a6f33f?d=identicon)[jpangborn](/maintainers/jpangborn)

---

Tags

phplaravelopensearchdriverscout

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[babenkoivan/elastic-scout-driver

Elasticsearch driver for Laravel Scout

2824.1M7](/packages/babenkoivan-elastic-scout-driver)[babenkoivan/elastic-scout-driver-plus

Extension for Elastic Scout Driver

2883.1M3](/packages/babenkoivan-elastic-scout-driver-plus)[romangrinev/laravel-opensearch-engine

Custom Laravel Scout OpenSearch Engine

1320.1k](/packages/romangrinev-laravel-opensearch-engine)

PHPackages © 2026

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