chrisgrim
1 month ago
154
3
Laravel

How to Tell If Elastic Search with Scout is setup correctly

Posted 1 month ago by chrisgrim

Hi, I followed this tutorial https://medium.com/@samogorm/basic-search-functionality-with-elasticsearch-laravel-scout-6ac182c99cbf to setup Scout and Elastic Search. I had no errors throughout the entire process but when I try to do a search it returns an empty array. I even created a new model for event named work and then have

    public function search(Request $request)
    {
        return Event::search('work')->get();

    }
}

Yet it returns an empty array. Is there a way to check what models have been imported with php artisan scout:import App\Event? Or to verify that it even worked? Like I said, everything seemed to install perfectly with the tutorial so I can't understand what is going wrong. Here is my event.php model

<?php

namespace App;

use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;

class Event extends Model
{
    use Searchable;

my app.php

      Laravel\Scout\ScoutServiceProvider::class,
      ScoutEngines\Elasticsearch\ElasticsearchProvider::class,

My scout.php

  'driver' => env('SCOUT_DRIVER', 'elasticsearch'),

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

in my .env file

ELASTICSEARCH_INDEX=scout
ELASTICSEARCH_HOST=http://localhost:9200

and when I go to that port I can see elasticsearch is up and running

Thanks!

Please sign in or create an account to participate in this conversation.