Configuring Elastic Search


Introduction

The search utilities in Pyro run on top of Laravel's Scout package. This tutorial explains how to setup the Elastic Search driver.

Install Dependencies

composer require tamayo/laravel-scout-elastic:~2

Add ElasticSearch Driver Provider

Open /config/app.php and edit:

'providers' => [
    ...
    ScoutEngines\Elasticsearch\ElasticsearchProvider::class,
], 

Add ElasticSearch Configuration

Open /config/scout.php and edit:

'elasticsearch' => [
    'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
    'config' => [
        'hosts' => [
            env('ELASTICSEARCH_HOST', 'localhost'),
        ],
    ],
], 

Set 'elasticsearch' as your Scout Driver in .env file:

SCOUT_DRIVER=elasticsearch

Additionally, specify your ElasticSearch host and index name:

ELASTICSEARCH_INDEX=mypyroindex
ELASTICSEARCH_HOST=search.myhost.com

Test by importing Model to ElasticSearch:

php artisan scout:import 'Anomaly\PostsModule\Post\PostModel'