Reputation: 4567
I am using rails with elasticsearch, thanks to the elasticsearch-rails gem ( https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence )
I am using the repository model as described in the documentation, I can change the index, but is it possible to use the alias feature of ES? If so, how? Example:
require 'elasticsearch/persistence'
repository = Elasticsearch::Persistence::Repository.new
repository.index = "myindex"
works fine, but no indication on how to create an alias
Upvotes: 3
Views: 1666
Reputation: 61
Update alias without downtime
client = Elasticsearch::Client.new
# or other es client
client.indices.update_aliases body: {
actions: [
{ remove: { index: 'your_old_index_name', alias: 'your_alias_name' } },
{ add: { index: 'your_new_index_name', alias: 'your_alias_name' } }
]
}
Upvotes: 1
Reputation: 751
client = Elasticsearch::Client.new
# or other es client
client.indices.update_aliases body: {
actions: [
{ add: { index: 'your_index_name', alias: 'your_alias_name' } }
]
}
Upvotes: 3