How can I stop Algolia from deleting all records when reimporting them using Laravel Scout?

40 Views Asked by At

I'm experiencing an issue with Laravel Scout and Algolia: executing php artisan scout:import "App\Models\Product" results in the Algolia index first being cleared of all products before reimporting them.

Is there a method to reimport the products such that they overwrite the existing ones instead of clearing the index first?

I'm aiming to minimize the downtime of my search services linked to Algolia during product data or configuration updates.

I tried to fix this by developing a command to update products individually. But this approach proved to be inefficient due to its slow processing speed. Also, I found issues with Algolia, which raised complaints regarding the limitations on the number of individual updates.

1

There are 1 best solutions below

0
Aken Roberts On

Algolia's Scout Extended package includes a scout:reimport command that does the zero downtime data replacement you're looking for: Zero Downtime Reimports.

When working in your production environment, you want to keep your existing search experience available while reimporting your data. You can do this with the scout:reimport Artisan command:

php artisan scout:reimport

To ensure not to interrupt searches happening on the index during the rebuild, Scout Extended uses a temporary index to import all records before moving it to the production index.

Warning: With this operation, your app temporarily has twice the number of records. Please verify that your plan includes enough available records to execute this operation.