Elastic Search Upgrade in Ruby On Rails from 0.90 to 2.x

278 Views Asked by At

In My current Ruby on Rails application elasticsearch is implememnted, the version of elasticsearch is 0.90 and we used "tire" gem.

Now I want to update it with latest version of elasticsearch("2.x").

Tier gem is now not supporting elasticsearch version 1.x/2.x, They are suggesting to use "elasticsearch-rails" gem but how to migrate my application from old to new by using this.

1

There are 1 best solutions below

0
On

Well, beside the obvious modification in Gemfile and bundle, you'll have to modify your models for starters:

I suggest you check the ES-rails GitHub: the ReadMe is very well documented.

The general idea is to include

include Elasticsearch::Model
include Elasticsearch::Model::Callbacks

in each of your models and then use ElasticSearch DSL as much as possible.

The point if you want to index your model in a different form from source code (i.e. public properties) is to create a def as_indexed_json() that will be used by ES when indexing.

Everything is (also) well documented in the ES-model GitHub

(WARNING: the 'main' elasticsearch-rails repo contains the 3 gem repos so you'll have to navigate inside repo tree to find the ReadMe file that suits you !)

If you detail a bit more your needs, we might be able to help you more !