UGA Boxxx

つぶやきの延長のつもりで、知ったこと思ったこと書いてます

【Elasticsearch】複数indexがひもづくaliasへの更新はできない

複数のindexをまとめてaliasを定義している

この時、一斉にこの複数のindexに対して更新をかけたい時に、aliasを指定すれば更新できるのかと考えたが以下のエラーが出てできなかった

index [my-index-alias], type [_doc], id [12345], message [ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=no write index is defined for alias [my-index-alias]. The write index may be explicitly disabled using is_write_index=false or the alias points to multiple indices without one being designated as a write index]]]

結論、複数のindexにひもづくaliasを指定しての更新はできないのでこのやり方は断念する

alias定義時に、ある1つのindexにis_write_index=trueをつければ更新できるようなのだが、これはやりたいことと異なるのでやらない

POST _aliases
{
    "actions": [
        { "add": { "index": "my-index-1", "alias": "my-index-alias", "is_write_index": true } },
        { "add": { "index": "my-index-2", "alias": "my-index-alias" } }
    ]
}

www.elastic.co