Skip to content

Latest commit

 

History

History
68 lines (56 loc) · 1.98 KB

index_management.md

File metadata and controls

68 lines (56 loc) · 1.98 KB

Index Management Plugin

You can use the Index Management Plugin (ISM) API to programmatically automate periodic, administrative operations on indexes by triggering them based on changes in the index age, index size, or number of documents.

Create a Policy

policy_name = "test-policy"

policy_content = {
    "policy": {
        "description": "hot warm delete workflow",
        "default_state": "hot",
        "schema_version": 1,
        "states": [
            {
                "name": "hot",
                "actions": [{"rollover": {"min_index_age": "1d"}}],
                "transitions": [{"state_name": "warm"}],
            },
            {
                "name": "warm",
                "actions": [{"replica_count": {"number_of_replicas": 5}}],
                "transitions": [{"state_name": "delete", "conditions": {"min_index_age": "30d"}}],
            },
            {
                "name": "delete",
                "actions": [
                    {
                        "notification": {
                            "destination": {"chime": {"url": "<URL>"}},
                            "message_template": {"source": "The index {{ctx.index}} is being deleted"},
                        }
                    },
                    {"delete": {}},
                ],
            },
        ],
        "ism_template": {"index_patterns": ["log*"], "priority": 100},
    }
}

response = client.index_managment.put_policy(policy_name, body=policy_content)
print(response)

Get a Policy

policy_name = "test-policy"

response = client.index_managment.get_policy(policy_name)
print(response)

Delete a Policy

policy_name = "test-policy"

response = client.index_managment.delete_policy(policy_name)
print(response)