DBAtlas · データベース運用アトラス

コンポーネントテンプレートからインデックステンプレートを構築し、結果をシミュレーションする

Elasticsearchインデックスのライフサイクル

コマンド

PUT _component_template/app-mappings
{
  "template": {
    "mappings": {
      "dynamic": "strict",
      "properties": {
        "@timestamp": { "type": "date" },
        "level": { "type": "keyword" },
        "msg": { "type": "text" }
      }
    }
  }
}
PUT _index_template/app-events
{
  "index_patterns": ["app-events-*"],
  "priority": 500,
  "composed_of": ["app-mappings"],
  "template": { "settings": { "number_of_shards": 1, "refresh_interval": "5s" } }
}
# See the final settings and mapping before the index is created:
POST _index_template/_simulate_index/app-events-000001
GET _cat/templates?v&s=name

概要

再利用可能なマッピングのコンポーネントテンプレートを定義し、それをインデックステンプレートに組み込み、インデックスを作成せずに、指定したインデックス名に適用される最終的な設定とマッピングを表示する。

使用する場面

新しいインデックスが誤ったマッピングやシャード数で作成される場合 (dynamic mapping の爆発、keyword ではなく text)、およびテンプレートの変更を展開する前に。

注意

テンプレートは新しく作成されるインデックスにのみ適用され、既存のインデックスのマッピングは変わらない (reindex-alias-swap を参照)。2 つのテンプレートが同じパターンに一致する場合、priority が最も高いものだけが使用され、マージはされない。dynamic: strict は未定義のフィールドを含むドキュメントを拒否する。アプリケーションが新しいフィールドを送ると、インデックス作成は失敗する。

DBAtlas で開く →

関連項目