PHPackages                             hendrydevries/laravel-scout-opensearch - 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. hendrydevries/laravel-scout-opensearch

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

hendrydevries/laravel-scout-opensearch
======================================

OpenSearch engine for Laravel Scout

v1.1(2y ago)019MITPHPPHP ^8.0

Since Jan 24Pushed 2y agoCompare

[ Source](https://github.com/hendrydevries/Laravel-Scout-OpenSearch)[ Packagist](https://packagist.org/packages/hendrydevries/laravel-scout-opensearch)[ RSS](/packages/hendrydevries-laravel-scout-opensearch/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

OpenSearch Engine for Laravel Scout
===================================

[](#opensearch-engine-for-laravel-scout)

This package provides an [OpenSearch](https://opensearch.org/) engine for [Laravel Scout](https://laravel.com/docs/9.x/scout). It's built on top of the latest release of Laravel Scout and lets you use OpenSearch as a driver for Scout.

Features
--------

[](#features)

- Laravel Scout 9 support
- Fully configurable settings per index, with default settings support
- Optionally mappings configurable
- Cursor pagination

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

[](#requirements)

- PHP &gt;= 8.0
- Laravel &gt;= 8

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

[](#installation)

You can include this package via Composer:

`composer require "hendrydevries/laravel-scout-opensearch"`

Add / set environment variables (in .env):

`SCOUT_DRIVER=Hendrydevries\LaravelScoutOpenSearch\Engines\OpenSearchEngine`

Add your OpenSearch host(s): (You can seperate multiple hosts with a comma)

`OPENSEARCH_HOSTS=http://localhost:9200`

If you have any web authentication on your OpenSearch cluster, you can extend the `opensearch.client` config.

Basic authentication:

```
    'client' => [
        'hosts' => explode(',', env('OPENSEARCH_HOSTS')),
        'basicAuthentication' => [
            env('OPENSEARCH_USERNAME'),
            env('OPENSEARCH_PASSWORD'),
        ],
    ],
```

Usage
-----

[](#usage)

Before you can use custom index settings and mappings, you have to publish the config to your application:

`php artisan vendor:publish --tag "opensearch-config"`

After changing indexes you have to create the index:

If the index already exists, delete it first:

`php artisan scout:delete-index yourSearchableAsValue`

Then you can create the index:

`php artisan scout:index yourSearchableAsValue`

The index is at this point completely empty. You can import existing data as described in the Laravel Scout documentation:

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

### Index settings

[](#index-settings)

Some [index settings](https://opensearch.org/docs/latest/opensearch/rest-api/index-apis/create-index/#index-settings) are static and can only be set on index creation. That's why it is important to configure it - when you have specific whishes - before you start using an index.

You can find an example in `opensearch.indices.default.settings`. Default is the key as default / fallback configuration. When you want a setting for a specific index, you use `opensearch.indices.yourSearchableAsValue.settings`.

### Mappings

[](#mappings)

Sometimes you need specific field mappings in OpenSearch. For example, when you use UUID's, the field type is automatically set to `text` and it can be usefull to have them as `keyword` in filters.

You can find an example in `opensearch.indices.table.mappings`. Table is in this case your index name.

### Search

[](#search)

You can search data as documented by Laravel in [their docs](https://laravel.com/docs/9.x/scout#searching). Because this search query uses query\_string in the search query to OpenSearch, it is possible to execute complex queries, such as:

- Star Trek
- the wind AND (rises OR rising)
- status:active Pencil

### Cursor pagination

[](#cursor-pagination)

Cursor pagination uses [search\_after](https://opensearch.org/docs/latest/opensearch/search/paginate#the-search_after-parameter) parameter pagination.

```
    Song::search("crass")
        ->orderBy("_score", "desc")
        ->orderBy("id")
        ->cursorPaginate(10);
```

If no sorting provided, the \_id field will be used as default, and therefore no relevance sorting can be applied when using cursor pagination.

#### Cursor pagination with sort mode

[](#cursor-pagination-with-sort-mode)

```
    Song::search()
        ->orderByRaw(
            new FieldSort('stars', 'desc', ['mode' => 'avg'])
        )
        ->orderBy('id')
        ->cursorPaginate(10);
```

#### Cursor pagination with nested object sort

[](#cursor-pagination-with-nested-object-sort)

```
    Article::search()
        ->orderByRaw(
            (new FieldSort('comments.created_at', 'desc', ['mode' => 'max']))
                ->setNestedFilter(new NestedSort('comments'))
        )
        ->orderBy('id')
        ->cursorPaginate(10);
```

#### Cursor pagination with \_geo\_distance

[](#cursor-pagination-with-_geo_distance)

```
    Store::search()
        ->orderByRaw(new FieldSort(
            '_geo_distance',
            'desc',
            [
                'point' => [10, 10],
                'unit' => 'km',
                'distance_type' => 'arc',
                'mode' => 'min',
                'ignore_unmapped' => true
            ]
        ))
        ->orderBy('id')
        ->cursorPaginate(10);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.7% 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 ~1 days

Total

2

Last Release

838d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/62230c41546bfa8d510bf18faa1890b95e77d7bad62f1aa55fd54cb848965766?d=identicon)[hendrydv](/maintainers/hendrydv)

---

Top Contributors

[![panzer-punk](https://avatars.githubusercontent.com/u/25403209?v=4)](https://github.com/panzer-punk "panzer-punk (33 commits)")[![daannet](https://avatars.githubusercontent.com/u/3153179?v=4)](https://github.com/daannet "daannet (16 commits)")[![hendrydv](https://avatars.githubusercontent.com/u/51476325?v=4)](https://github.com/hendrydv "hendrydv (2 commits)")

---

Tags

searchlaravelawsopensearchscout

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hendrydevries-laravel-scout-opensearch/health.svg)

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

###  Alternatives

[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[teamtnt/laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch

1.1k2.5M28](/packages/teamtnt-laravel-scout-tntsearch-driver)[cloudmediasolutions/laravel-scout-opensearch

OpenSearch engine for Laravel Scout

1824.4k](/packages/cloudmediasolutions-laravel-scout-opensearch)[zing/laravel-scout-opensearch

Laravel Scout custom engine for OpenSearch

33340.2k](/packages/zing-laravel-scout-opensearch)[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.3M6](/packages/algolia-scout-extended)[vanry/laravel-scout-tntsearch

包含中文分词的 Laravel Scout TNTSearch 驱动，支持 scws, phpanalysis 和 jieba 分词。

17811.8k1](/packages/vanry-laravel-scout-tntsearch)

PHPackages © 2026

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