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

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

shufo/laravel-opensearch
========================

An easy way to use the official PHP OpenSearch client in your Laravel applications.

v0.2.2(2y ago)58.8kMITPHPPHP ^7.3|^8.0

Since Sep 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/shufo/laravel-opensearch)[ Packagist](https://packagist.org/packages/shufo/laravel-opensearch)[ Docs](https://github.com/shufo/laravel-opensearch)[ RSS](/packages/shufo-laravel-opensearch/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (9)Versions (13)Used By (0)

Laravel-OpenSearch
==================

[](#laravel-opensearch)

⚠️ This package is still in alpha. Don't use in production.

An easy way to use the [official OpenSearch client](https://github.com/opensearch-project/opensearch-php) in your Laravel applications.

This is the fork of [laravel-elasticsearch](https://github.com/cviebrock/laravel-elasticsearch).

Installation and Configuration
------------------------------

[](#installation-and-configuration)

Add repository to your composer.json

```
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/shufo/opensearch-php"
    }
  ],
```

then

```
composer require shufo/laravel-opensearch
```

### Laravel

[](#laravel)

The package's service provider will automatically register its service provider.

Publish the configuration file:

```
php artisan vendor:publish --provider="Shufo\LaravelOpenSearch\ServiceProvider"
```

To change host of opensearch, set `OPENSEARCH_HOST` environment variable to your opensearch hostname.

To edit config you can edit `config/opensearch.php`.

```
$ vim config/opensearch.php
```

Usage
-----

[](#usage)

With Facade:

```
// search
>>> OpenSearch::search([
    'index' => 'example',
    'body'  => [
        'query' => [
            'match' => [
                'id' => '123'
            ]
        ]
    ]
])
=> [
     "took" => 1,
     "timed_out" => false,
     "_shards" => [
       "total" => 1,
       "successful" => 1,
       "skipped" => 0,
       "failed" => 0,
     ],
     "hits" => [
       "total" => [
         "value" => 1,
         "relation" => "eq",
       ],
       "max_score" => 0.6931471,
       "hits" => [
         [
           "_index" => "example",
           "_type" => "_doc",
           "_id" => "1",
           "_score" => 0.6931471,
           "_source" => [
             "id" => "123",
             "body" => "test",
           ],
         ],
       ],
     ],
   ]

// create index
OpenSearch::indices()->create([
    'index' => 'example',
    'body' => [
        'mappings' => [
            'properties' => [
                'id' => [
                    'type' => 'long',
                ],
                'text' => [
                    'type' => 'text',
                ]
            ]
        ]
    ],
])

// add document to index
OpenSearch::index([
    "id" => "123",
    "body" => [
        "id" => "123",
        "text" => "foo",
    ],
    "index" => "example",
]);

// delete index
OpenSearch::indices()->delete(['index' => 'example']);

// SQL (currently it's available only select operation)
>>> OpenSearch::sql()->query(["query" => "select * from example", "fetch_size" => 1])
=> [
     "schema" => [
       [
         "name" => "body",
         "type" => "text",
       ],
       [
         "name" => "id",
         "type" => "keyword",
       ],
     ],
     "cursor" => "d:eyJhIjp7fSwicyI6IkZHbHVZMngxWkdWZlkyOXVkR1Y0ZEY5MWRXbGtEWEYxWlhKNVFXNWtSbVYwWTJnQkZrTmZVamR0VEc1ZlUwSmxOM2h4U2w5bFRWQjRaMUVBQUFBQUFBQUFxaFpqUjFGckxVRm9YMUl6Vnpkc2NXaHlabkk1VFZGbiIsImMiOlt7Im5hbWUiOiJib2R5IiwidHlwZSI6InRleHQifSx7Im5hbWUiOiJpZCIsInR5cGUiOiJrZXl3b3JkIn1dLCJmIjoxLCJpIjoiZXhhbXBsZSIsImwiOjF9",
     "total" => 2,
     "datarows" => [
       [
         "test",
         "123",
       ],
     ],
     "size" => 1,
     "status" => 200,
   ]
```

With Opensearch Client Builder:

```
use OpenSearch\ClientBuilder;

$data = [
    'body' => [
        'testField' => 'abc'
    ],
    'index' => 'my_index',
    'type' => 'my_type',
    'id' => 'my_id',
];

$client = ClientBuilder::create()->build();
$return = $client->index($data);
```

Contributing
------------

[](#contributing)

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

LICENSE
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~47 days

Recently: every ~79 days

Total

8

Last Release

1007d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/93a795940c00cb3124dab69958e06b4f56aa8d906f98eb8408b3a930ed0d46b3?d=identicon)[shufo](/maintainers/shufo)

---

Top Contributors

[![shufo](https://avatars.githubusercontent.com/u/1641039?v=4)](https://github.com/shufo "shufo (32 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

laravelopensearchclientsearchlaravelopensearch

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[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)[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.3M6](/packages/algolia-scout-extended)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[spatie/laravel-site-search

A site search engine

300129.1k](/packages/spatie-laravel-site-search)

PHPackages © 2026

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