Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reindex): merge of settings in reindex method #389

Closed
wants to merge 2 commits into from

Conversation

chloelbn
Copy link
Contributor

@chloelbn chloelbn commented Nov 4, 2020

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related Issue Fix #357
Need Doc update no

Describe your change

In the reindex method, when using a tmp index, base configuration of the index was copied regardless of changes that could have been made, causing an error especially if the deprecated attributesToIndex parameter was used. This fixes this issue.

spec/integration_spec.rb Show resolved Hide resolved
tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)
end
::Algolia::copy_index!(src_index_name, tmp_index_name, %w(settings synonyms rules))
tmp_index = SafeIndex.new(tmp_index_name, !!options[:raise_on_failure])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you understand why @julienbourdeau introduced this test in ba94561 ? I'm not sure I get it, even though I think I'm fine with your updated version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that it was to avoid having to make multiple calls to get_settings, but the problem was that the configuration described in the model, even though it might have changed later, was in that case pulled back and that was what caused the issue I'm trying to fix. But what I'm not not sure I understand indeed was the need to pull back this configuration. I may be changing the behaviour and I do need @julienbourdeau enlighten on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, the new version is not going to apply setting changes anymore. I added the check_settings options to avoid many get/set settings call. Scoped copy indexed feature was just introduced.

Issues about searchableAttributes vs attributeToIndex should be addressed by updating the code in the algoliasearch block to use the new name.

I this this PR is going to create more issue that it solves. We should definitely encourage people to turn off the check_settings feature. Especially, if the "fix" is to ensure people use the code for "check_settings = false".

Copy link
Contributor

@julienbourdeau julienbourdeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue this PR is trying to fix should be addressed otherwise. Mostly docs and helping people update their config. Many implementation won't be applying new settings automatically with this change.

For sure, we shouldn't be adding more magic to handle searchableAttributes vs attributeToIndex and such

tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)
end
::Algolia::copy_index!(src_index_name, tmp_index_name, %w(settings synonyms rules))
tmp_index = SafeIndex.new(tmp_index_name, !!options[:raise_on_failure])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, the new version is not going to apply setting changes anymore. I added the check_settings options to avoid many get/set settings call. Scoped copy indexed feature was just introduced.

Issues about searchableAttributes vs attributeToIndex should be addressed by updating the code in the algoliasearch block to use the new name.

I this this PR is going to create more issue that it solves. We should definitely encourage people to turn off the check_settings feature. Especially, if the "fix" is to ensure people use the code for "check_settings = false".

@chloelbn chloelbn closed this Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Model.reindex raises AlgoliaProtocolError: "attributesToIndex" is deprecated
3 participants