1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

elasticsearchのインデックス操作でインデックス名の先頭にハイフンつけた場合の挙動

Last updated at Posted at 2016-03-22

先頭ハイフンなしのインデックス作成

$ curl -XPUT "http://es-test.bashishi.local/index001?pretty"
{
  "acknowledged" : true
}

$ curl -XPUT "http://es-test.bashishi.local/index002?pretty"
{
  "acknowledged" : true
}

$ curl -XPUT "http://es-test.bashishi.local/index003?pretty"
{
  "acknowledged" : true
}

当然問題なく作成される。

先頭ハイフン付きのインデックスを作成

$ curl -XPUT "http://es-test.bashishi.local/-index999?pretty"
{
  "acknowledged" : true
}

問題なく作成できる。
一応、一覧を表示してみる。

$ curl -XGET "http://es-test.bashishi.local/_alias?pretty"
{
  "index001" : {
    "aliases" : { }
  },
  "index002" : {
    "aliases" : { }
  },
  "index003" : {
    "aliases" : { }
  },
  "-index999" : {
    "aliases" : { }
  }
}

ちゃんとある。

先頭ハイフンのインデックスがある状態で、そのインデックスを削除してみる。

$ curl -XDELETE "http://es-test.bashishi.local/-index999?pretty"
{
  "acknowledged" : true
}
$ curl -XGET "http://es-test.bashishi.local/_alias?pretty"
{
  "index001" : {
    "aliases" : { }
  },
  "index002" : {
    "aliases" : { }
  },
  "index003" : {
    "aliases" : { }
  }
}

ちゃんと削除できる。

インデックスの先頭にハイフンを付けて削除してみる。

index003 が存在する状態で、削除するインデックス名として -index003を指定する。

$ curl -XDELETE "http://es-test.bashishi.local/-index003?pretty"
{
  "acknowledged" : true
}

index003以外が削除される。

$ curl -XGET "http://es-test.bashishi.local/_alias?pretty"
{
  "index003" : {
    "aliases" : { }
  }
}

存在しないインデックスの先頭にハイフン付けて削除しようとすると 404 NotFound になる。

$ curl -XDELETE "http://es-test.bashishi.local/-index004/?pretty"
{
  "error" : "IndexMissingException[[index004] missing]",
  "status" : 404
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?