PHPackages                             synergy/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. synergy/scout-elasticsearch-driver

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

synergy/scout-elasticsearch-driver
==================================

The Elasticsearch Driver for Laravel Scout

v2.1.0(4y ago)2611[15 PRs](https://github.com/odiaseo/scout-elasticsearch-driver/pulls)MITPHPPHP &gt;=7.4

Since Sep 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/odiaseo/scout-elasticsearch-driver)[ Packagist](https://packagist.org/packages/synergy/scout-elasticsearch-driver)[ Docs](https://odiaseo.github.io/scout-elasticsearch-driver/)[ RSS](/packages/synergy-scout-elasticsearch-driver/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (9)Versions (47)Used By (0)

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

[](#laravel-scout-elasticsearch-driver)

[![Latest Stable Version](https://camo.githubusercontent.com/2403294e39e13dc9c994bf39a4fa857242b61222b1c636f377098707231e1c26/68747470733a2f2f706f7365722e707567782e6f72672f73796e657267792f73636f75742d656c61737469637365617263682d6472697665722f762f737461626c65)](https://packagist.org/packages/synergy/scout-elasticsearch-driver)[![Total Downloads](https://camo.githubusercontent.com/7e7bba9eeea3b23056d7e06e2333d0d07198e4de5b52ea92bf933bc56931c2a6/68747470733a2f2f706f7365722e707567782e6f72672f73796e657267792f73636f75742d656c61737469637365617263682d6472697665722f646f776e6c6f616473)](https://packagist.org/packages/synergy/scout-elasticsearch-driver)[![composer.lock](https://camo.githubusercontent.com/0cfb96bab981c62320bc23aeca66b691b20e3e81d20373894bdd292bc36b19e4/68747470733a2f2f706f7365722e707567782e6f72672f73796e657267792f73636f75742d656c61737469637365617263682d6472697665722f636f6d706f7365726c6f636b)](https://packagist.org/packages/synergy/scout-elasticsearch-driver)[![Build Status](https://camo.githubusercontent.com/ec96404884f00e796cc7863fedb81026c1973fbec658dd36ffdf0cfc685234ce/68747470733a2f2f7472617669732d63692e6f72672f6f64696173656f2f73636f75742d656c61737469637365617263682d6472697665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/odiaseo/scout-elasticsearch-driver)[![Coverage Status](https://camo.githubusercontent.com/0a4b0f97a9168960b77c3b58f1aea6cdfa01d0e0d73c68eb1043c1aeaad64b5d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f64696173656f2f73636f75742d656c61737469637365617263682d6472697665722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/odiaseo/scout-elasticsearch-driver?branch=master)

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

Contents
--------

[](#contents)

- [Tutorial](#tutorial)
- [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)
- [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.

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

[](#requirements)

The package has been tested in the following configuration:

- PHP version &gt;= 7.0
- Laravel Framework version &gt;= 5.5
- Elasticsearch version &gt;= 5.5

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

[](#installation)

Use composer to install the package:

```
composer require synergy/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="SynergyScoutElastic\providers\SynergyScoutElasticServiceProvider"

```

Then, set the driver setting to `elastic` in the `config/scout.php` file and configure the driver itself in the `config/synergy-scout-elastic.php` file. There are two available options:

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`.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, settings and default mapping like in the following example:

```
