I would like to have a clear understanding on how to deal with the following scenario:
I'm adding or removing an attribute from an activerecord model, so I want to update its mapping in ElasticSearch, in production.
From what I understood, I should...
1- create a new index and import everything from mysql
Is this the right command? rake environment tire:import CLASS='Bow' INDEX='new-bows'
For this to create the right mapping, I should already have updated my mapping in the model, right?
2- delete the old mapping and create an alias named bows
for new-bows
I would do it like that, is it correct?
old_index_name = Bow.tire.index.name
Bow.tire.index.delete
alias = Tire::Alias.new
alias.name(old_index_name)
alias.index('new-bows')
alias.save
3- restart app
Am I missing something, or is there a simpler way to achieve what I want using Tire?
At what point should I delete the old index? Before creating the alias with the same name, or can I do it after?