This content has been automatically translated from Ukrainian.
When setting up the SearchBox search add-on on Heroku, an error occurred while starting the indexing from the console.
Loading production environment (Rails 7.0.4.3) irb(main):001:0> Document.__elasticsearch__.create_index! force: true The client is unable to verify that the server is Elasticsearch. Some functionality may not be compatible if the server is running an unsupported product. /app/vendor/bundle/ruby/3.2.0/gems/elasticsearch-8.17.1/lib/elasticsearch.rb:103:in `verify_elasticsearch’:ssupport this unknown product. (Elasticsearch::UnsupportedProductError)
The following libraries were installed in the latest versions (8):
gem 'elasticsearch-model' gem 'elasticsearch-rails'
The official documentation states:
Ensure you are using client version of 7 if you get error The client noticed that the server is not a supported distribution of Elasticsearch while connecting to your endpoint.
But it won't be possible to lock the versions of elasticsearch-model and elasticsearch-rails to 7, as they depend on elasticsearch 8 or 7.17 (which also does not suit us)
irb(main):001:0> Topic.__elasticsearch__.create_index! force: true /app/vendor/bundle/ruby/3.2.0/gems/elasticsearch-7.17.11/lib/elasticsearch.rb:86:in `verify_with_version_or_header': The client noticed that the server is not a supported distribution of Elasticsearch. (Elasticsearch::UnsupportedProductError)
So the best option is to add elasticsearch to the Gemfile and lock it to the required version 7.
gem 'elasticsearch', '7.0.0' gem 'elasticsearch-model', '7.0.0' gem 'elasticsearch-rails', '7.0.0'
But it’s better to consider alternative add-ons on Heroku, like Bonsai. They use the latest versions of libraries with the necessary patches. Security above all.
This post doesn't have any additions from the author yet.