algoliasearch-rails icon indicating copy to clipboard operation
algoliasearch-rails copied to clipboard

Reindex silently fails to update settings when settings are misconfigured

Open ersinakinci opened this issue 5 years ago • 1 comments

  • Rails version: 5.2.4.3
  • Algolia Rails integration version: 1.24.0
  • Algolia Client Version: 1.27.3
  • Language Version: Ruby

Description

If your model's settings are incorrectly configured, .reindex! will update your index while silently failing to update your index's settings. There's no indication given that anything is misconfigured, making any problems with your settings difficult to diagnose.

Steps To Reproduce

I have a Rails model that looks like this:

class MyModel
  algoliasearch do
    attribute :title
    attribute :name

    attributesForFaceting [:title, :name]  # Correctly configured
    customRanking ['asc(title)', 'name'] # Incorrectly configured, name must be 'asc(name)' or 'desc(name)'
  end
end

Running MyModel.reindex! will reindex correctly, but customRanking and attributesForFaceting will silently fail to update because customRanking is incorrectly configured.

There should be an error given so that the user can fix the problem.

ersinakinci avatar Jun 30 '20 16:06 ersinakinci

As a partial workaround, it's possible to see the errors by running MyModel.algolia_set_settings, which will visibly fail if your settings are incorrectly configured.

ersinakinci avatar Jun 30 '20 16:06 ersinakinci