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

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

amitavroy/laravel-elastic
=========================

A package to give the ability to index data on Elastic search and allow to searh on individual models.

v1.1.1(7y ago)036MITPHP

Since Oct 24Pushed 7y ago1 watchersCompare

[ Source](https://github.com/amitavroy/laraelastic)[ Packagist](https://packagist.org/packages/amitavroy/laravel-elastic)[ Docs](https://github.com/amitavroy/laravel-elastic)[ RSS](/packages/amitavroy-laravel-elastic/feed)WikiDiscussions master Synced today

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

A simple wrapper to use Elastic search with Laravel Eloquent models.
====================================================================

[](#a-simple-wrapper-to-use-elastic-search-with-laravel-eloquent-models)

This package will allow you to use Elastic search along with your Eloquent models with ease. This package will create individual indexes for each model of your application and using the Eloquent events 'created', 'updated' and 'deleted' this package will keep your Elastic index in sync.

Installation and usage
----------------------

[](#installation-and-usage)

This package best works with Elastic search 6.0 and above.

To install, you just need to require the package using the following command

```
composer require amitavroy/laravel-elastic

```

Setup and configuration
-----------------------

[](#setup-and-configuration)

This package comes with a configuration file which you will need to publish and set the host array. This is how the package is going to access the Elastic search instance.

```
'hosts' => [
    'http://localhost:6200',
],

```

Also, you can define a prefix to your indexes in case you are using the same Elastic search instance for multiple application.

```
'prefix' => 'some_prefix_',

```

Usage
-----

[](#usage)

This package provides a trait which you need to add to any Eloquent model that you want to be indexed and searched. And, you need to mention which fields of that model you want to search on. For example, you don't want to store and search the user's password, the remember token or some other sensitive data.

```
