PHPackages                             mabadir/elastic-laravel - 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. [API Development](/categories/api)
4. /
5. mabadir/elastic-laravel

AbandonedLibrary[API Development](/categories/api)

mabadir/elastic-laravel
=======================

Elastic Search Indexer for Laravel 5

1.1.4(8y ago)3311MITPHPPHP ~5.6|~7.0

Since Mar 20Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mabadir/elastic-laravel)[ Packagist](https://packagist.org/packages/mabadir/elastic-laravel)[ Docs](https://github.com/mabadir/elastic-laravel)[ RSS](/packages/mabadir-elastic-laravel/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

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

[](#elastic-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b2432e93b8002bd716165eecf5b7d7ae5f910e490634e03ff941b45751a53c21/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6162616469722f656c61737469632d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mabadir/elastic-laravel)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Quality Score](https://camo.githubusercontent.com/f126ebaf306a3fe413d5e92b91b351a2997906af6b27a93926ba391ba4c1014d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d6162616469722f656c61737469632d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/mabadir/elastic-laravel)[![Total Downloads](https://camo.githubusercontent.com/97250cfab9f3f2a5a870d711ec75eae1679ff991f7305fad69151c78eedda83c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6162616469722f656c61737469632d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mabadir/elastic-laravel)

Elastic Search Indexer for Laravel 5.

Structure
---------

[](#structure)

If any of the following are applicable to your project, then the directory structure should follow industry best practises by being named the following.

```
config/
src/
tests/
vendor/

```

Install
-------

[](#install)

Via Composer

```
$ composer require mabadir/elastic-laravel
```

Usage
-----

[](#usage)

Add the `ElasticLaravelServiceProvider` to your `config/app.php`.

```
'providers' => [
//Other providers
    MAbadir\ElasticLaravel\ElasticLaravelServiceProvider::class,
],
```

Publish the `elastic.php` to your configuration.

```
$ php artisan vendor:publish
```

Add the ElasticEloquent trait to your Eloquent model to have it indexed.

```
namespace App;

use MAbadir\ElasticLaravel\ElasticEloquent;

class User extends Authenticatable
{
    use ElasticEloquent;

}
```

For searching the index, you can run search with different approaches. The first step is to add the Facade to your `config/app.php`:

```
'aliases' => [
    //Other Facades
   'ElasticSearcher' => MAbadir\ElasticLaravel\ElasticSearcher::class,
],
```

1. Simple term search:

```
ElasticSearcher::search('simple term');
```

2. Simple term search on specific model type:

```
$user = App\User::first();
ElasticSearcher::search('Simple Term', $user);
```

This will search the Elastic Search index for the simple term with `type=users`.

3. Search index on specific parameter:

```
ElasticSearcher::search(['name' => 'First Name']);
```

This will search the complete Search Index for the parameter name with value `First Name`

4. Search index on specific parameter and specific model type:

```
$user = App\User::first();
ElasticSearcher::search(['name' => 'First Name'], $user);
```

This will search the Search Index for the parameter name with value `First Name` on `type=users`.

5. Advanced Search:

```
$params = [
            'body' => [
                'query' => [
                    'match' => [
                        '_all' => 'Simple Term'
                    ]
                ]
            ]
        ];
ElasticSearcher::advanced($params);
```

This exposes the complete Elastic Search powerful query DSL interface, this will accept any acceptable Elastic Search DSL query.

6. Advanced Search:

```
$user = User::first();
$params = [
            'body' => [
                'query' => [
                    'match' => [
                        '_all' => 'Simple Term'
                    ]
                ]
            ]
        ];
ElasticSearcher::advanced($params, $user);
```

This will search the index using the advanced query for `type=users`.

For the different functions, the class name can be used instead of the object itself, the object or the class should be extending Eloquent Model class `\Illuminate\Database\Eloquent\Model`. For example:

```
ElasticSearcher::search(['name' => 'First Name'], User::class);
```

#### ElasticSearch Indexing Console Command

[](#elasticsearch-indexing-console-command)

By default the package provides a default index initialization command:

```
$ php artisan es:init

```

The default command will initialize the index with very basic settings. If it is required to initialize the index with more advanced settings and custom mappings: Create a new Console Command in your application:

```
$ php artisan make:command IndexIntializationCommand

```

Import the `IndexInitializationTrait` class, and overload the `$params` attribute:

```
namespace App\Console\Commands;

use Illuminate\Console\Command;
use MAbadir\ElasticLaravel\Console\IndexInitializationTrait;

class IndexIntializationCommand extends Command
{
    use IndexInitializationTrait;

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'es:initialize';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Initialize ElasticSearch Index';

    /**
     * Parameters array
     *
     * @var array
     */
    protected $params = [
        //Custom Settings
    ];
}
```

For more details on the configuration parameters, check the official [ElasticSearch documentation](https://www.elastic.co/guide/en/elasticsearch/client/php-api/5.0/_index_management_operations.html).

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mina Abadir](https://github.com/mabadir)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~38 days

Total

8

Last Release

3232d ago

Major Versions

0.1.0 → 1.0.02017-03-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3389914?v=4)[Mina Abadir](/maintainers/mabadir)[@mabadir](https://github.com/mabadir)

---

Tags

mabadirelastic-laravel

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[riclep/laravel-storyblok

A Laravel wrapper around the Storyblok API to provide a familiar experience for Laravel devs

6277.0k5](/packages/riclep-laravel-storyblok)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.1k1](/packages/jasara-php-amzn-selling-partner-api)[rapidez/core

Rapidez Core

1822.4k65](/packages/rapidez-core)

PHPackages © 2026

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