Skip to content

Instantly share code, notes, and snippets.

@TomonoriSoejima
Last active January 19, 2023 01:34
Show Gist options
  • Save TomonoriSoejima/e312ae06b8072bcb665106706ab205d4 to your computer and use it in GitHub Desktop.
Save TomonoriSoejima/e312ae06b8072bcb665106706ab205d4 to your computer and use it in GitHub Desktop.
ilm.md
  • testing cold thing
PUT _ilm/policy/test-cold-policy
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0s",
        "actions": {
          "set_priority": {
            "priority": 100
          }
        }
      },
      "warm": {
        "min_age": "5s",
        "actions": {
          "set_priority": {
            "priority": 50
          }
        }
      },
      "cold": {
        "min_age": "10s",
        "actions": {
          "searchable_snapshot": {
            "snapshot_repository": "found-snapshots"
          }
        }
      }
    }
  }
}


PUT _template/test-cold-template
{
  "index_patterns": ["test-cold-index*"],
  "settings": {
    "lifecycle": {
      "name": "test-cold-policy"
    },
    "number_of_shards": 1,
    "number_of_replicas": 0
  }
}


POST test-cold-index-1/_doc/1
{
  "field1": "newvalue"
}



GET test-cold-index-1/_ilm/explain



GET _cat/shards?v
# create ilm policy for frozen
DELETE _ilm/policy/test-frozen-policy
PUT _ilm/policy/test-frozen-policy
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0m",
        "actions": {
          "set_priority": {
            "priority": 100
          }
        }
      },
      "warm": {
        "min_age": "2m",
        "actions": {
          "set_priority": {
            "priority": 50
          }
        }
      },
      "cold": {
        "min_age": "4m",
        "actions": {
          "set_priority": {
            "priority": 100
          },
          "allocate": {
            "number_of_replicas": 0
          }
        }
      },
      "frozen": {
        "min_age": "6m",
        "actions": {
          "searchable_snapshot": {
            "snapshot_repository": "found-snapshots"
          }
        }
      }
    }
  }
}


# create template for frozen indices
DELETE _template/test-frozen-template
PUT _template/test-frozen-template
{
  "index_patterns": ["test-frozen-index*"],
  "settings": {
    "lifecycle": {
      "name": "test-frozen-policy"
    },
    "number_of_shards": 1
  }
}

# create index for frozen
DELETE test-frozen-index-1
POST test-frozen-index-1/_doc
{
  "field1": "someValue"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment