Search code examples
laravel-5.3algoliastaginglaravel-scout

Laravel Scout & Algolia - can't create index on staging server after migrating from TNTSearch to Algolia


this is very weird. I've successfully created an index on my local server and it showed up in Algolia dashbord.

However, when I ran php artisan scout:import 'App\MyModel' on my staging server I get:

Imported [App\MyModel] models up to ID: 22
All [App\MyModel] records have been imported.

but the index doesn't show up in Algolia dashboard.

I've compared my .env files and these fields are the same on both of my apps:

SCOUT_DRIVER=algolia
SCOUT_PREFIX=staging_ //this one is "development_" on my local server 
ALGOLIA_APP_ID=aaaaa
ALGOLIA_MONITORING_KEY=bbbbb
ALGOLIA_SEARCH=ccccc
ALGOLIA_SECRET=ddddd

my config/scout.php

'driver' => env('SCOUT_DRIVER', 'algolia'),
'prefix' => env('SCOUT_PREFIX', ''),
'queue' => true,
'algolia' => [
    'id' => env('ALGOLIA_APP_ID', ''),
    'secret' => env('ALGOLIA_SECRET', ''),
],

and here is my config/algolia.php

'default' => 'main',
'connections' => [

    'main' => [
        'id' => env('ALGOLIA_APP_ID'),
        'key' => env('ALGOLIA_SECRET'),
    ],
    'alternative' => [
        'id' => 'your-application-id',
        'key' => 'your-api-key',
    ],

],

Any help is appreciated. Thanks!

UPDATE

It seems that index file my_models.index in the storage folder gets updated when I run php artisan scout:import 'App\MyModel'

I believe this is a leftover from using TNTSearch before Algolia but I can't figure out why is my app using TNTSearch and not Algolia one on my staging server.

I concluded this because when I run php artisan scout:import 'App\MyModel' this index file gets updated on my staging server but not on my local machine.

UPDATE #2

ssh into server, inside of php artisan tinker I get algolia if I run env('SCOUT_DRIVER') or config('scout.driver').

UPDATE #3

Tried the php artisan config:clear and cache:clear but I still get new my_model.index file after I run the scout:import on my model. Even after I've deleted all mention of TNT from .env, composer.json and AppServiceProvider.php.


Solution

  • Restarting the server fixed it!