# Elasticsearch Serviceの既存indexの更新時のダウンタイムについて

**URL:** <https://discuss.elastic.co/t/elasticsearch-service-index/201331>\
**Category:** 日本語による質問・議論はこちら\
**Created:** [September 27, 2019, 3:44am UTC](https://discuss.elastic.co/t/elasticsearch-service-index/201331 "2019-09-27T03:44:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Masanori\_Mishima](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masanori_mishima/32/45030_2.png) [@Masanori\_Mishima](https://discuss.elastic.co/u/Masanori_Mishima)\
**Post date:** [September 27, 2019, 3:44am UTC](https://discuss.elastic.co/t/elasticsearch-service-index/201331/1 "2019-09-27T03:44:30Z")

</div>

ドキュメントの元ネタであるCSVの更新があった時に既存indexを一度削除して既存indexと同じmappingやsettingでindexを再作成してCSVをドキュメントとしてロードしようと考えているのですが、  
このときElasticsearch Service上のインスタンスにダウンタイムを発生させないようにするためには、  
deploymentを2つ(稼働用と更新用)用意しておいて、更新用のdeploymentでデプロイをしてから  
稼働用のsnapshotメニューのRestore from another DeploymentからRestoreすれば良いのでしょうか？

---

<div class="post-metadata">

**Author:** ![tsgkdt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsgkdt/32/39151_2.png) [@tsgkdt](https://discuss.elastic.co/u/tsgkdt)\
**Post date:** [September 27, 2019, 4:44am UTC](https://discuss.elastic.co/t/elasticsearch-service-index/201331/2 "2019-09-27T04:44:33Z")

</div>

aliasという機能を使えば実現できそうに見えます。

[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#indices-aliases-api-example](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#indices-aliases-api-example)

利用イメージです。  
既存のIndexにaliasをつけておき、普段の検索などはそのaliasに対して行うようにしておきます。

```auto
POST /_aliases
{
    "actions" : [
        { "add" : { "index" : "test1", "alias" : "alias1" } }
    ]
}

```

test1というindexに対して、alias1という名前をつけます。  
普段使いの検索はalias1に対して行うようにします。 (例 POST alias1/\_search )

indexの作成しなおしが発生し、新しいIndexを作成しおわったら、作成していたaliasに対して、新しいIndexを参照するように設定します。

```auto
POST /_aliases
{
    "actions" : [
        { "remove" : { "index" : "test1", "alias" : "alias1" } },
        { "add" : { "index" : "new_test", "alias" : "alias1" } }
    ]
}

```

alias1に対して、test1が削除され、new\_testが設定されます。  
alias1/\_searchで検索すると、test1ではなく、new\_testから検索されます。

このようにすれば、aliasの設定先を切り替えるだけで済むため、ダウンタイムがないかと思います。

ご参考になれば幸いです。

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 25, 2019, 4:44am UTC](https://discuss.elastic.co/t/elasticsearch-service-index/201331/3 "2019-10-25T04:44:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
