PHPackages                             shortcodes/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. [Search &amp; Filtering](/categories/search)
4. /
5. shortcodes/scout-elasticsearch-driver

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

shortcodes/scout-elasticsearch-driver
=====================================

The Elasticsearch Driver for Laravel Scout

v5.0.2(3y ago)12.4kMITPHPPHP &gt;=7.1.3

Since Apr 5Pushed 3y agoCompare

[ Source](https://github.com/shortcodes/scout-elasticsearch-driver)[ Packagist](https://packagist.org/packages/shortcodes/scout-elasticsearch-driver)[ Docs](https://babenkoivan.github.io/scout-elasticsearch-driver/)[ RSS](/packages/shortcodes-scout-elasticsearch-driver/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (44)Used By (0)

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

[](#scout-elasticsearch-driver)

[![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)[![Gitter](https://camo.githubusercontent.com/37b71e1ce183f4ee630f818196f982c56f4c223c1d829b4d6baa0c3a07fdcf9f/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f6e776a732f6e772e6a732e737667)](https://gitter.im/scout-elasticsearch-driver/Lobby)[![Donate](https://camo.githubusercontent.com/ae330d33706db436cdd131659cf5dec4f9468fadd5bec2f270a775b4f2c4b658/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d50617950616c2d626c75652e737667)](https://www.paypal.me/ivanbabenko)

🍺 If you like my package, it'd be nice of you [to buy me a beer](https://www.paypal.me/ivanbabenko).

![:octocat:](https://github.githubassets.com/images/icons/emoji/octocat.png ":octocat:") The project has a [chat room on Gitter](https://gitter.im/scout-elasticsearch-driver/Lobby)!

---

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)

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
- Laravel Framework version &gt;= 5.6
- Elasticsearch version &gt;= 6

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

[](#installation)

Use composer to install the package:

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

```

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 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`.track\_scoresBy default the track\_scores is set to `true`.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:

```
