PHPackages                             ideea/scout-elasticsearch-driver - 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. [Database &amp; ORM](/categories/database)
4. /
5. ideea/scout-elasticsearch-driver

ActiveLibrary[Database &amp; ORM](/categories/database)

ideea/scout-elasticsearch-driver
================================

The Elasticsearch Driver for Laravel Scout

0429PHP

Since Dec 28Pushed 3y agoCompare

[ Source](https://github.com/ideea/scout-elasticsearch-driver)[ Packagist](https://packagist.org/packages/ideea/scout-elasticsearch-driver)[ RSS](/packages/ideea-scout-elasticsearch-driver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Scout Elasticsearch Driver
==========================

[](#scout-elasticsearch-driver)

💥 **Introducing [a new Elasticsearch ecosystem for Laravel](#alternatives).** 💥

---

[![Packagist](https://camo.githubusercontent.com/984cbeaf74b89ce019bb191511f80c88677fa0f83bd2d8e81810744e5896997a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626162656e6b6f6976616e2f73636f75742d656c61737469637365617263682d6472697665722e737667)](https://packagist.org/packages/babenkoivan/scout-elasticsearch-driver)[![Packagist](https://camo.githubusercontent.com/137b0dadf1d8c21e5f6c36b05315cfa5cf57c9223e13a9b3f01f55d013bc9cf2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626162656e6b6f6976616e2f73636f75742d656c61737469637365617263682d6472697665722e737667)](https://packagist.org/packages/babenkoivan/scout-elasticsearch-driver)[![Build Status](https://camo.githubusercontent.com/965fd502fd74d884e4c2718a91096ba7e4e3fe6138f154360659ee59ce6d4944/68747470733a2f2f7472617669732d63692e636f6d2f626162656e6b6f6976616e2f73636f75742d656c61737469637365617263682d6472697665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/babenkoivan/scout-elasticsearch-driver)[![Donate](https://camo.githubusercontent.com/ae330d33706db436cdd131659cf5dec4f9468fadd5bec2f270a775b4f2c4b658/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d50617950616c2d626c75652e737667)](https://www.paypal.me/babenkoi)

---

This package offers advanced functionality for searching and filtering data in Elasticsearch. Check out its [features](#features)!

Contents
--------

[](#contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Index configurator](#index-configurator)
- [Searchable model](#searchable-model)
- [Usage](#usage)
- [Console commands](#console-commands)
- [Search rules](#search-rules)
- [Available filters](#available-filters)
- [Zero downtime migration](#zero-downtime-migration)
- [Debug](#debug)
- [Alternatives](#alternatives)

Features
--------

[](#features)

- An easy way to [configure](#index-configurator) and [create](#console-commands) an Elasticsearch index.
- A fully configurable mapping for each [model](#searchable-model).
- A possibility to add a new field to an existing mapping [automatically](#configuration) or using [the artisan command](#console-commands).
- Lots of different ways to implement your search algorithm: using [search rules](#search-rules) or a [raw search](#usage).
- [Various filter types](#available-filters) to make a search query more specific.
- [Zero downtime migration](#zero-downtime-migration) from an old index to a new index.
- Bulk indexing, see [the configuration section](#configuration).

Requirements
------------

[](#requirements)

The package has been tested in the following configuration:

- PHP version &gt;=7.1.3, &lt;=7.3
- Laravel Framework version &gt;=5.8, &lt;=6
- Elasticsearch version &gt;=7

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

[](#installation)

Use composer to install the package:

```
composer require babenkoivan/scout-elasticsearch-driver

```

If you are using Laravel version &lt;= 5.4 or [the package discovery](https://laravel.com/docs/5.5/packages#package-discovery)is disabled, add the following providers in `config/app.php`:

```
'providers' => [
    Laravel\Scout\ScoutServiceProvider::class,
    ScoutElastic\ScoutElasticServiceProvider::class,
]
```

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

[](#configuration)

To configure the package you need to publish settings first:

```
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
php artisan vendor:publish --provider="ScoutElastic\ScoutElasticServiceProvider"

```

Then, set the driver setting to `elastic` in the `config/scout.php` file (or set `SCOUT_DRIVER=elastic` in the `.env`) and configure the driver itself in the `config/scout_elastic.php` file. The available options are:

OptionDescriptionclientA setting hash to build Elasticsearch client. More information you can find [here](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/configuration.html#_building_the_client_from_a_configuration_hash). By default the host is set to `localhost:9200`.update\_mappingThe option that specifies whether to update a mapping automatically or not. By default it is set to `true`.indexerSet to `single` for the single document indexing and to `bulk` for the bulk document indexing. By default is set to `single`.document\_refreshThis option controls when updated documents appear in the search results. Can be set to `'true'`, `'false'`, `'wait_for'` or `null`. More details about this option you can find [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html). By default set to `null`.Note, that if you use the bulk document indexing you'll probably want to change the chunk size, you can do that in the `config/scout.php` file.

Index configurator
------------------

[](#index-configurator)

An index configurator class is used to set up settings for an Elasticsearch index. To create a new index configurator use the following artisan command:

```
php artisan make:index-configurator MyIndexConfigurator

```

It'll create the file `MyIndexConfigurator.php` in the `app` folder of your project. You can specify index name and settings like in the following example:

```
