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

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

haridarshan/opensearch-scout-driver-plus
========================================

Extension for OpenSearch Scout Driver

v1.0.0(2y ago)025MITPHPPHP ^7.4 || ^8.0

Since Mar 9Pushed 2y agoCompare

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

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

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

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

---

Extension for [OpenSearch Scout Driver](https://github.com/haridarshan/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)
- [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 OpenSearch Scout Driver Plus has been tested with the following configuration:

- PHP 7.4-8.x
- OpenSearch 2.x
- Laravel 7.x-10.x
- Laravel Scout 7.x-10.x

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

[](#installation)

The library can be installed via Composer:

```
composer require haridarshan/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/haridarshan/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 haridarshan/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.

If you want to use OpenSearch Scout Driver Plus with [Lumen framework](https://lumen.laravel.com/)refer to [this guide](https://github.com/haridarshan/opensearch-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 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)
- [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)
- [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)

### 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/haridarshan/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

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

795d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cc037296dcecf54ee9d5584cefdefe081c6a250c66b2d566e341f5051225b7d?d=identicon)[haridarshan](/maintainers/haridarshan)

---

Top Contributors

[![babenkoivan](https://avatars.githubusercontent.com/u/25812954?v=4)](https://github.com/babenkoivan "babenkoivan (239 commits)")[![spiritinlife](https://avatars.githubusercontent.com/u/6434983?v=4)](https://github.com/spiritinlife "spiritinlife (15 commits)")[![haridarshan](https://avatars.githubusercontent.com/u/1327607?v=4)](https://github.com/haridarshan "haridarshan (7 commits)")[![Jackardios](https://avatars.githubusercontent.com/u/24757335?v=4)](https://github.com/Jackardios "Jackardios (6 commits)")[![hendrikheil](https://avatars.githubusercontent.com/u/19904485?v=4)](https://github.com/hendrikheil "hendrikheil (1 commits)")[![petsoukos](https://avatars.githubusercontent.com/u/1178259?v=4)](https://github.com/petsoukos "petsoukos (1 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)")

---

Tags

phplaravelopensearchdriverscout

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/haridarshan-opensearch-scout-driver-plus/health.svg)](https://phpackages.com/packages/haridarshan-opensearch-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)[romangrinev/laravel-opensearch-engine

Custom Laravel Scout OpenSearch Engine

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

PHPackages © 2026

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