PHPackages                             yong/elasticsuit - 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. [Database &amp; ORM](/categories/database)
4. /
5. yong/elasticsuit

ActiveLibrary[Database &amp; ORM](/categories/database)

yong/elasticsuit
================

Eloquent ORM encapsulation of Elasticsearch for Laravel

5.7(4y ago)2151MITPHPPHP &gt;=7.1

Since Dec 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yongchengchen/laravel-elasticsearch)[ Packagist](https://packagist.org/packages/yong/elasticsuit)[ RSS](/packages/yong-elasticsuit/feed)WikiDiscussions master Synced 1mo ago

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

Laravel ElasticSuit
-------------------

[](#laravel-elasticsuit)

[![Total Downloads](https://camo.githubusercontent.com/9bedfeb31ec8827208b72308050d85a8f5dfb1f2d0cc6bcee8e096c9d33fdddc/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f656c6173746963737569742f642f746f74616c2e737667)](https://packagist.org/packages/yong/elasticsuit)[![Latest Stable Version](https://camo.githubusercontent.com/8d224a63b3f373de444b9b5c9875a4e16d0999a5b6c388b551735d9c32f49ed8/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f656c6173746963737569742f762f737461626c652e737667)](https://packagist.org/packages/yong/elasticsuit)[![Latest Unstable Version](https://camo.githubusercontent.com/0415b78c35232b94463e4802bba21d228b3371a98505d4e8763641c00c8f05a9/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f656c6173746963737569742f762f756e737461626c652e737667)](https://packagist.org/packages/yong/elasticsuit)[![License](https://camo.githubusercontent.com/21f3ae4fdf0274fddf318c4cb064507355c1b295a6fc8285cb6ff6eeaafe468c/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f656c6173746963737569742f6c6963656e73652e737667)](https://packagist.org/packages/yong/elasticsuit)

This is a package to integrate Elasticsearch to Laravel5

It makes you do Elasticsearch just using Eloquent's API.

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

[](#installation)

1. Require this package with composer:

```
composer require yong/elasticsuit dev-master
```

2. Add service provider to config/app.php

```
Yong\ElasticSuit\Service\Provider;
```

3. Add elasticsearch node configuration to the "connections" node of config/database.php

```
        'elasticsearch' => [
            'hosts'=>['127.0.0.1:9200'],
            'ismultihandle'=>0,
            'database'=> 'db*',
            'prefix' => '',
            'settings'=> ['number_of_shards'=>2,'number_of_replicas'=>0]
        ],
```

Usage
-----

[](#usage)

1. Define a model for a elasticsearch type

```
class TestModel extends \Yong\ElasticSuit\Elasticsearch\Model {
    protected $connection = 'elasticsearch';
    protected $table = 'testmodel';

    //relations
    public function Childmodel () {
        return $this->hasOne(OtherModel::class, '_id');
    }
}
```

2. Create a new document

```
$testmodel = new TestModel();
$testmodel->first_name = 'firstname';
$testmodel->last_name = 'lastname';
$testmodel->age = 20;
$testmodel->save();
```

3. Search a collection

```
$collection = TestModel::where('first_name', 'like', 'firstname')
    ->whereIn('_id', [1,2,3,4,5])
    ->whereNotIn('_id', [5,6,7,8,9])
    ->where('_id', '=', 1)
    ->where('age', '>', 18)
    ->orWhere('last_name', 'like', 'lastname')
    ->whereNull('nick_name')
    ->whereNotNull('age')
    ->whereMultMatch(['last_name', 'description'], 'search words', '60%')
    ->skip(10)
    ->forPage(1, 20)
    ->take(10)
    ->limit(10)
    ->select(['first_name', 'last_name', 'age'])
    ->get();

* also support sum(), avg(), min(), max(), stats(), count()
* but not for all fields, only numeric fields can use aggregate
```

4. Relations It also support relations, but remember so far just support using default \_id as primary key.

```
    //get relations
    TestModel::with('childmodel')->where('first_name', 'like', 'firstname')->get();
```

License
-------

[](#license)

And of course:

MIT:

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~1790 days

Total

2

Last Release

1649d ago

PHP version history (2 changes)5.2PHP &gt;=5.5.9

5.7PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6c816f6595690bacefe660ceaad1fb84db75236828249549519e1f533af3da9?d=identicon)[Yongcheng](/maintainers/Yongcheng)

---

Top Contributors

[![yongchengchen](https://avatars.githubusercontent.com/u/11036128?v=4)](https://github.com/yongchengchen "yongchengchen (11 commits)")

---

Tags

elasticsearchlaravel5php5laravelelasticsearchormeloquent

### Embed Badge

![Health badge](/badges/yong-elasticsuit/health.svg)

```
[![Health](https://phpackages.com/badges/yong-elasticsuit/health.svg)](https://phpackages.com/packages/yong-elasticsuit)
```

###  Alternatives

[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[sleimanx2/plastic

Plastic is an Elasticsearch ODM and mapper for Laravel. It renders the developer experience more enjoyable while using Elasticsearch by providing a fluent syntax for mapping , querying and storing eloquent models.

508141.9k1](/packages/sleimanx2-plastic)[matchory/elasticsearch

The missing elasticsearch ORM for Laravel!

3059.0k](/packages/matchory-elasticsearch)[crcms/elasticsearch

Use SQL statements to query elasticsearch

1058.3k1](/packages/crcms-elasticsearch)[fadion/bouncy

Map Elasticsearch results to Eloquent models

7116.3k](/packages/fadion-bouncy)

PHPackages © 2026

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