Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

elasticsearch alias with rails

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

like image 616
tomsoft Avatar asked Nov 24 '25 16:11

tomsoft


1 Answers

client = Elasticsearch::Client.new 
# or other es client
client.indices.update_aliases body: {
  actions: [
    { add: { index: 'your_index_name', alias: 'your_alias_name' } }
  ]
}
like image 71
xguox Avatar answered Nov 26 '25 07:11

xguox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!