put-lifecycle.asciidoc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-put-lifecycle]]
  4. === Create Lifecycle Policy API
  5. ++++
  6. <titleabbrev>Create Policy</titleabbrev>
  7. ++++
  8. Creates or updates lifecycle policy.
  9. ==== Request
  10. `PUT _ilm/policy/<policy_id>`
  11. ==== Description
  12. Creates a lifecycle policy. If the specified policy exists, the policy is
  13. replaced and the policy version is incremented.
  14. NOTE: Only the latest version of the policy is stored, you cannot revert to
  15. previous versions.
  16. ==== Path Parameters
  17. `policy` (required)::
  18. (string) Identifier for the policy.
  19. ==== Request Parameters
  20. include::{docdir}/rest-api/timeoutparms.asciidoc[]
  21. ==== Authorization
  22. include::ilm-cluster-mgt-privilege.asciidoc[]
  23. ==== Examples
  24. The following example creates a new policy named `my_policy`:
  25. [source,js]
  26. --------------------------------------------------
  27. PUT _ilm/policy/my_policy
  28. {
  29. "policy": {
  30. "phases": {
  31. "warm": {
  32. "min_age": "10d",
  33. "actions": {
  34. "forcemerge": {
  35. "max_num_segments": 1
  36. }
  37. }
  38. },
  39. "delete": {
  40. "min_age": "30d",
  41. "actions": {
  42. "delete": {}
  43. }
  44. }
  45. }
  46. }
  47. }
  48. --------------------------------------------------
  49. // CONSOLE
  50. // TEST
  51. If the request succeeds, you receive the following result:
  52. [source,js]
  53. ----
  54. {
  55. "acknowledged": true
  56. }
  57. ----
  58. // CONSOLE
  59. // TESTRESPONSE