PHPackages                             kevinyan/laravel-elastic - 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. kevinyan/laravel-elastic

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

kevinyan/laravel-elastic
========================

Elasticsearch fluent interface for Laravel 5

0.0.6(7y ago)3468MITPHPPHP &gt;=7.0

Since Oct 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kevinyan815/laravel-elastic)[ Packagist](https://packagist.org/packages/kevinyan/laravel-elastic)[ RSS](/packages/kevinyan-laravel-elastic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

laravel-elastic
===============

[](#laravel-elastic)

Elasticsearch Fluent interface for Laravel5

Now just have a very rough version impelements elasticsearch's basic search functionality.

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

[](#installation)

- get package from packagist

```
composer requrire kevinyan/laravel-elastic

```

- register service provider and facade in `config/app.php` （In laravel version 5.5 or higher, you can skip this step)

```
'providers' => [
    ...
    KevinYan\Elastic\Providers\ElasticServiceProvider::class,

]

'aliases' => [
    ...
    'Elastic'   => KevinYan\Elastic\Facades\Elastic::class
]

```

- publish configuration file into project's config directory

```
php artisan vendor:publish --provider="KevinYan\Elastic\Providers\ElasticServiceProvider"

```

Configuration
-------------

[](#configuration)

Our configuration file is well documented, but there's one thing to emphasize. Since in elasticsearch version 6 type was removed, if your elasticsearch server is higher than 6, be sure not to set `type` config option in configuration file.

Usage
-----

[](#usage)

```
// resolve elastic service from IocContainer, this will connect to the default elastic connection
$elastic = app()->make('elastic')
// connection to an specific connection
$elastic = app()->make('elastic')->connection('connection name');

// we have three different types of  term : must, should and filter, default type is must.
// search using a must term
$elastic->select(['title', 'author', 'published_at'])->term('author', 'kevin')
        ->setTimeRange('2016-01-02 12:00:00', '2016-06-05 16:23:00)->latest()
        ->get();
// search using a must term and a should term
$elastic->select(['title', 'author', 'published_at'])->term('author', 'kevin')->term('category', '10010', 'should')
        ->setTimeRange('2016-01-02 12:00:00', '2016-06-05 16:23:00)->latest()
        ->get();

// scrolling
# The Scrolling functionality of Elasticsearch is used to paginate over many documents in a bulk manner,
# such as exporting all the documents belonging to a single user.
# It is more efficient than regular from + size search because it doesn’t need to maintain an expensive
# priority queue ordering the documents.

$result = $elastic->select(['title', 'author'])->term('author', 'kevin')->get();

//this package will automatically maintain scroll_id which is used to continue paginating through the hits
while($result && count($result) > 0) {
    //loop until the scroll "cursors" are exhausted
    $result = $elastic->srcoll();
    ...
}

```

Sometime you may need to find out what elasticsearch returns for your search action. You can simply dump using `dump` method, this method will dump all raw returns from elasticsearch to output(browser or standard output) and then end the script :

```
$result = $elastic->select(['title', 'author'])->term('author', 'kevin')->dump();

```

### Use Facade

[](#use-facade)

The package comes with a facade,if you prefer the static method calls over dependency injection.

Replace `app()->make('elastic')` with `Elastic::` in the examples above.

Contact
-------

[](#contact)

Open an issue on GitHub if you have any problems or suggestions.

License
-------

[](#license)

The contents of this repository is released under the MIT license.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

6

Last Release

2739d ago

### Community

Maintainers

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

---

Top Contributors

[![kevinyan815](https://avatars.githubusercontent.com/u/8792672?v=4)](https://github.com/kevinyan815 "kevinyan815 (24 commits)")

---

Tags

activerecordcomposercomposer-packageelasticsearchfluent-apilaravel

### Embed Badge

![Health badge](/badges/kevinyan-laravel-elastic/health.svg)

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

###  Alternatives

[mailerlite/laravel-elasticsearch

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

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[baijunyao/laravel-scout-elasticsearch

Elasticsearch Driver for Laravel Scout

8023.7k1](/packages/baijunyao-laravel-scout-elasticsearch)

PHPackages © 2026

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