put-lifecycle.asciidoc 1.3 KB

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