Reputation: 9269
I'm working on a Laravel project and I'm using https://laravel.com/docs/5.3/scout with ElasticSearch on a model Offer.
With the command php artisan scout:import "App\Models\Offer"
I can generate an index for ElasticSearch with offers
from my database, and it's ok. After that I can search offers
in this index.
But now, I removed somes offers
from my database, and I don't know how can I reset or re-generate the index for remove old ids ?
For example I removed Offer with id = 15
in my database, but when I do a search, this offer (id=15) is always indexed, and I get an error because this offer doesn't exist.
I tried to re run the command scout:import
but no effect. The only solution I fond is to rename the index with https://laravel.com/docs/master/scout#configuring-model-indexes but I can't do that each times...
Any ideas ?
Upvotes: 1
Views: 4465
Reputation: 4320
You can use php artisan scout:flush "App\Models\Offer"
You can also remove physical files for indexes from storage
folder
Upvotes: 1
Reputation: 79
The driver should automatically remove/update the record when you do a remove/update on any Model declared as Searchable.
To flush the models use: php artisan scout:import Model
You could check the bugs area for laravel-scout, maybe there is something related or try an update to L5.4
Upvotes: 0