meilisearch / strapi-plugin-meilisearch

A strapi plugin to add your collections to Meilisearch
https://meilisearch.com
MIT License
223 stars 58 forks source link

Selected collections to index for Meilisearch reset on reboot #695

Open sjorsjes opened 1 year ago

sjorsjes commented 1 year ago

Description I run Meilisearch and Strapi in a kubernetes environment. When Meilisearch and Strapi are running I can select the collections to index and everything is passed to Meilisearch and when I check the UI everything is indexed.

At the moment I have no volume set up for Meilisearch so when I reboot the container all indexes are gone. This normally only happens when I update the Meilisearch container and not really a problem for my situation.

But when this happens, in Strapi, not a single collection is selected for Indexing anymore and I have to manually turn them on again.

Expected behavior I would expect Strapi to remember the collections I want indexed and reapply the index (cron job?).

Current behavior Strapi resets all collections from being indexed.

Environment (please complete the following information):

bidoubiwa commented 1 year ago

Hey @sjorsjes

To confirm I understood your problem correctly. Sometimes you re-run your strapi without the Meilisearch running, which removes the checked boxes. Then, once you run Meilisearch again and relaunch Strapi, you expect the previously added collections to be re-indexed in Meilisearch?

The way it works today is as follows. When you select an Index on the plugin page, It will:

Whenever your re-run strapi (build or dev), the bootstrap files fetches all existing indexes in Meilisearch and all index names that are stored in Strapi. It compares the list and remove from the store every index that is not found in Meilisearch. For the ones that are still there, we add them to the collections we are listening to.

What you are suggesting is that on Strapi bootstrap, we take the list of indexes from the store, and instead of removing the ones missing in Meilisearch, we re-index them?

sjorsjes commented 1 year ago

Sorry for the late response, I was on holiday.

Whenever your re-run strapi (build or dev), the bootstrap files fetches all existing indexes in Meilisearch and all index names that are stored in Strapi. It compares the list and remove from the store every index that is not found in Meilisearch. For the ones that are still there, we add them to the collections we are listening to.

That explains why none of my collections are selected anymore after a reboot from Meilisearch (because all indexes are gone).

What you are suggesting is that on Strapi bootstrap, we take the list of indexes from the store, and instead of removing the ones missing in Meilisearch, we re-index them?

Yes! I would not use Meilisearch as a reference to check what collections should be indexed because it can happen that all indexes are gone.

brunoocasali commented 1 year ago

Hi @sjorsjes, just to inform you, @bidoubiwa is on holiday 🌴. You can expect a reply next week! 🎉

bidoubiwa commented 1 year ago

Hey @sjorsjes,

Lets add this behavior!