2016-12-05 57 views
1

我使用與elasticsearch軌,由於elasticsearch護欄寶石(https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistenceelasticsearch別名與軌道

我使用的文檔中描述的倉庫模型,我可以改變的指標,但有可能使用ES的別名功能?如果是這樣,怎麼樣? 例子:

require 'elasticsearch/persistence' 
repository = Elasticsearch::Persistence::Repository.new 
repository.index = "myindex" 

工作正常,但對如何創建別名

回答

0
client = Elasticsearch::Client.new 
# or other es client 
client.indices.update_aliases body: { 
    actions: [ 
    { add: { index: 'your_index_name', alias: 'your_alias_name' } } 
    ] 
} 
0

更新別名無需停機無指示

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' } } 
] 
}