[4.x] Add autocreate_on_save option for indexes #8866
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Statamic updates search indexes automatically, when an entry is saved. This includes creating a new index and filling it up completely, if none exists.
This is great for smaller sites, since one does not have to worry about the index at all - however, on larger sites with a lot of content and/or custom search indexers, that take a while to complete, this can end in a situation, where saving an entry is impossible due to the index creation.
This PR adds a
autocreate_on_save
option for indexes, which defaults totrue
.autocreate_on_save
is set totrue
then the current behaviour is preservedautocreate_on_save
is set tofalse
, then the index will be updated, if it already exists but it will not be automatically created, should it not exist. If the option is enabled, the index has to be created using other means (e.g. manually via CLI, cronjob, ...)Future outlook:
When this question originally was raised by my colleague, moving this work to a queue was also raised as an alternative. In my opinion, this would be a better solution altogether