All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

[Fix] Heroku / SearchBox addon - indexing error "The client is unable to verify that the server is Elasticsearch"

Post cover: [Fix] Heroku / SearchBox addon - indexing error "The client is unable to verify that the server is Elasticsearch"
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.

[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)
07 Dec 10:46

[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)

meme code
meme code@memecode
What is PORO in Ruby?
08 Dec 12:46

What is PORO in Ruby?

meme code
meme code@memecode
What is the difference between spec_helper.rb and rails_helper.rb in RSpec?
08 Dec 13:53

What is the difference between spec_helper.rb and rails_helper.rb in RSpec?

meme code
meme code@memecode
09 Dec 14:50

[Fix] No such file or directory @ rb_sysopen - tmp/pids/server.pid

meme code
meme code@memecode
What you need to know to build a successful freelance career in IT
23 Dec 16:03

What you need to know to build a successful freelance career in IT

meme code
meme code@memecode
Virtual cloud server: what it is and what makes it special
03 Jan 10:58

Virtual cloud server: what it is and what makes it special

meme code
meme code@memecode
06 Feb 15:31

Fix error [DEPRECATION] #adapters is deprecated. Use #profiles instead. (Codecov / docile)

meme code
meme code@memecode
What is a Promise in JavaScript and how to quickly understand its essence?
18 Feb 11:01

What is a Promise in JavaScript and how to quickly understand its essence?

meme code
meme code@memecode
The structure of Promise (JavaScript) and how to work with it
18 Feb 14:33

The structure of Promise (JavaScript) and how to work with it

meme code
meme code@memecode
What is Memoization (examples in Ruby and Ruby on Rails)?
20 Feb 18:16

What is Memoization (examples in Ruby and Ruby on Rails)?

meme code
meme code@memecode
What is debounce in JavaScript and why is it important?
21 Mar 16:39

What is debounce in JavaScript and why is it important?

meme code
meme code@memecode
What is CFB (Cipher Feedback)?
21 Mar 16:53

What is CFB (Cipher Feedback)?

meme code
meme code@memecode