Fixed atomic reindex to ensure init when check_settings=true. #453
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.
What problem is this fixing?
Atomic reindex (ex:
Product.reindex
) is always going to create tmp index with empty setting. And index move completed, previous settings disappeared. Not only specified settings inside algoliasearch block, but manual setting on dashboard.How to Reproduce
app/models/product.rb
in rails console for instance
Describe your change
I understood the
check_settings
specification like this:When
check_settings: true
(default), all the index operation going under ActiveRecord respect the specified settings in algoliasearch block.On the other hand when
check_settings: false
, users just want to manage it on dashboard. So when new tmp index is to create, it just takes over the settings from existing index.If my understanding is true, I guess current implementation accidentally missed
algolia_ensure_init
for tmp index whencheck_settings=true
. I have imported that case from previous version below.https://github.com/algolia/algoliasearch-rails/blob/9c1a0a46ca3dd4487cc3461c755a3fef144db491/lib/algoliasearch-rails.rb#L554C23-L554C86