PHPackages                             harisant/laravel-elasticsearch - 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. harisant/laravel-elasticsearch

ActiveLibrary[API Development](/categories/api)

harisant/laravel-elasticsearch
==============================

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

03PHP

Since Dec 3Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel-Elasticsearch
=====================

[](#laravel-elasticsearch)

An easy way to use the [official Elastic Search client](https://github.com/elastic/elasticsearch-php) in your Laravel or Lumen applications.

[![Build Status](https://github.com/mailerlite/laravel-elasticsearch/workflows/tests/badge.svg?branch=master)](https://github.com/mailerlite/laravel-elasticsearch/actions)[![Total Downloads](https://camo.githubusercontent.com/df49774e7cf8fb82a2b8e7632ed8ade37ea49b17f2a477804fa4f94b654a14cb/68747470733a2f2f706f7365722e707567782e6f72672f6d61696c65726c6974652f6c61726176656c2d656c61737469637365617263682f646f776e6c6f6164732e706e67)](https://packagist.org/packages/mailerlite/laravel-elasticsearch)[![Latest Stable Version](https://camo.githubusercontent.com/b36fb5089ba6edb5f390aae83de71f78af06591fe0eff2df8a323af986cc64bc/68747470733a2f2f706f7365722e707567782e6f72672f6d61696c65726c6974652f6c61726176656c2d656c61737469637365617263682f762f737461626c652e706e67)](https://packagist.org/packages/mailerlite/laravel-elasticsearch)[![Latest Stable Version](https://camo.githubusercontent.com/6d57892a37ebe082f66948815be538679bda452c5b22bfe352f32fad1de42b07/68747470733a2f2f706f7365722e707567782e6f72672f6d61696c65726c6974652f6c61726176656c2d656c61737469637365617263682f762f756e737461626c652e706e67)](https://packagist.org/packages/mailerlite/laravel-elasticsearch)[![License](https://camo.githubusercontent.com/c805da922dbf83b3763446ecb6e765484002fe5171948a477c4df3579535508a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d61696c65726c6974652f6c61726176656c2d656c6173746963736561726368)](LICENSE.md)

- [Laravel-Elasticsearch](#laravel-elasticsearch)
    - [Installation and Configuration](#installation-and-configuration)
        - [Laravel](#laravel)
            - [Alternative configuration method via .env file](#alternative-configuration-method-via-env-file)
            - [Connecting to AWS Elasticsearch Service](#connecting-to-aws-elasticsearch-service)
        - [Lumen](#lumen)
    - [Usage](#usage)
    - [Advanced Usage](#advanced-usage)
    - [Console commands](#console-commands)
    - [Bugs, Suggestions, Contributions and Support](#bugs-suggestions-contributions-and-support)
    - [Copyright and License](#copyright-and-license)

Installation and Configuration
------------------------------

[](#installation-and-configuration)

Install the current version of the `mailerlite/laravel-elasticsearch` package via composer:

```
composer require mailerlite/laravel-elasticsearch
```

If you are using ElasticSearch version 5, then install version 2 of this package:

```
composer require mailerlite/laravel-elasticsearch:^2
```

### Laravel

[](#laravel)

The package's service provider will automatically register its service provider.

Publish the configuration file:

```
php artisan vendor:publish --provider="MailerLite\LaravelElasticsearch\ServiceProvider"
```

##### Alternative configuration method via .env file

[](#alternative-configuration-method-via-env-file)

After you publish the configuration file as suggested above, you may configure ElasticSearch by adding the following to your application's `.env` file (with appropriate values):

```
ELASTICSEARCH_HOST=localhost
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_SCHEME=http
ELASTICSEARCH_USER=
ELASTICSEARCH_PASS=
```

If you are logging in via API keys, you will need to fill in these values:

```
ELASTICSEARCH_API_ID=
ELASTICSEARCH_API_KEY=
```

##### Connecting to AWS Elasticsearch Service

[](#connecting-to-aws-elasticsearch-service)

If you are connecting to ElasticSearch instances on Amazon AWS, then you'll also need to `composer require aws/aws-sdk-php:^3.80` and add the following to your `.env` file:

```
AWS_ELASTICSEARCH_ENABLED=true
AWS_REGION=...
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
```

If you have to use another authentication method having custom credentials (i.e. `instanceProfile()`), you have to publish the configuration file and use the **aws\_credentials**:

```
