In order for an index to use an index lifecycle management policy to manage its lifecycle we must
first define a lifecycle policy for it to use. The following request creates a
policy called my_policy in Elasticsearch which we can later use to manage our
indexes.
PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_size": "25GB"  }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}  }
      }
    }
  }
}
        }
      }
    }
  }
}index lifecycle management will manage an index using the policy defined in the
index.lifecycle.name index setting. If this setting does not exist in the
settings for a particular index, index lifecycle management will not manage that index.
To set the policy for an index there are two options: