CreateILMPolicy
Creates an index lifecycle policy. If the specified policy name already exists, the existing policy is replaced and its version is incremented.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
elasticsearch:CreateILMPolicy |
none |
*All Resource
|
None | None |
Request syntax
POST /openapi/instances/{InstanceId}/ilm-policies HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| InstanceId |
string |
Yes |
The instance ID. |
es-cn-m7r23wodb006n**** |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. |
5A2CFF0E-5718-45B5-9D4D-70B3FF**** |
| body |
string |
No |
The name and phase configurations of the index lifecycle policy to be created. |
{"name":"my-policy","phases":{"delete":{"minAge":"30d","actions":{"delete":{}}}}} |
Request body
| Parameter | Type | Example | Required | Description |
| name | String | my-policy | Yes | The policy name of the index lifecycle policy. |
| phases | Map | No | The content of the index lifecycle policy. For more information, see Data structure of the phases field. |
Data structure of the phases field
| Parameter | Type | Example | Required | Description |
| {key} | Struct | No | The current lifecycle phase. Valid values: hot (the hot data phase, where the index is actively updated and queried), cold (the cold data phase, where the index is no longer updated and is rarely queried, but the information must still be searchable even if queries are slower), and delete (the delete phase, where the index is no longer needed and can be safely deleted). | |
| minAge | String | 30d | No | The time required for the index to reach the target phase. |
| actions | Struct | No | The policy settings for the current phase. For more information, see Data structure of the actions field. |
Data structure of the actions field
| Parameter | Type | Example | Required | Description |
| rollver | Struct | No | The index rollover operation in the hot phase. For more information, see Data structure of the rollver field. | |
| setPriority | Struct | No | The index priority in the hot or cold phase. For more information, see Data structure of the setPriority field. | |
| allocate | Struct | No | The allocation operation in the cold phase. For more information, see Data structure of the allocate field. | |
| delete | Struct | {} | No | The index deletion operation. This parameter is required and must be an empty object when the delete phase is enabled. |
Data structure of the rollver field
| Parameter | Type | Example | Required | Description |
| maxAge | String | 30d | No | The time threshold that triggers an index rollover. You must specify at least one of the maxAge, maxDocs, and maxSize parameters. Unit: d (days) or h (hours). |
| maxDocs | Integer | 10000 | No | The document count threshold that triggers an index rollover. |
| maxSize | String | 50gb | No | The index size threshold that triggers an index rollover. You must specify at least one of the maxAge, maxDocs, and maxSize parameters. Unit: MB or GB. |
Data structure of the setPriority field
| Parameter | Type | Example | Required | Description |
| priority | Integer | 100 | No | The default priority of the current node. |
Data structure of the allocate field
| Parameter | Type | Example | Required | Description |
| numberOfReplicas | Integer | 1 | No | The specified number of replicas to allocate. If this parameter is set, the default value is 1. This parameter is used together with migrate. When automatic migration is enabled, the number of replicas is allocated by default. |
| require | Struct | No | The optional settings. This parameter is available for clusters with a hot and cold data separation architecture. For more information, see Data structure of the require field. |
Data structure of the require field
| Parameter | Type | Example | Required | Description |
| boxType | String | warm | No | The custom node attribute identifier. This parameter is available for clusters with a hot and cold data separation architecture and is used to migrate data to cold nodes. Valid values: warm. |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Result |
string |
The name of the created index lifecycle policy. |
my-policy |
| RequestId |
string |
The request ID. |
F99407AB-2FA9-489E-A259-40CF6DCC**** |
Examples
Success response
JSON format
{
"Result": "my-policy",
"RequestId": "F99407AB-2FA9-489E-A259-40CF6DCC****"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.