Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amitavroy/laraelastic

This is a wrapper on top of elastic search to use with Laravel.
https://github.com/amitavroy/laraelastic

Last synced: about 7 hours ago
JSON representation

This is a wrapper on top of elastic search to use with Laravel.

Awesome Lists containing this project

README

        

# 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
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
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
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.

```