Search code examples
ruby-on-railselasticsearchsearchkick

How to fix 'undefined method `get_aliases' for #<Elasticsearch::API::Indices::IndicesClient:0x00007fc31b6ed558>'


I'm trying to set up ElasticSearch with the Searchkick gem on a Ruby on Rails (5.2.2) project. I'm following the setup instructions from https://github.com/ankane/searchkick but I'm getting the following error when I try adding data to the search index (running Modelname.reindex in the rails console).

NoMethodError: undefined method `get_aliases' for # 
<Elasticsearch::API::Indices::IndicesClient:0x00007fc31b6ed558>
Did you mean?  get_alias
from /Users/XXXX/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/searchkick-3.1.2/lib/searchkick/index.rb:104:in `all_indices'

I've tried uninstalling ElasticSearch and the Searchkick gem and reinstalling. And I've also tried changing get_aliases to get_alias in the index.rb file.

Modelname.reindex should allow me to add data to the search index.


Solution

  • I just ran into the same issue. It seems to be a problem with Searchkick relying on something that was removed from Elasticsearch in the latest version of the Elasticsearch gem (which was released literally 10 hours ago).

    Hopefully it will be fixed soon, but if you really need it to work right now, putting this in your Gemfile should fix it:

    gem 'elasticsearch', '~> 6.2.0'