diff --git a/docs/reference/data-streams/change-mappings-and-settings.asciidoc b/docs/reference/data-streams/change-mappings-and-settings.asciidoc index 7f6f8cc9b1342..b17b47120a41a 100644 --- a/docs/reference/data-streams/change-mappings-and-settings.asciidoc +++ b/docs/reference/data-streams/change-mappings-and-settings.asciidoc @@ -320,6 +320,10 @@ PUT /my-data-stream/_settings ---- -- +IMPORTANT: To change the `index.lifecycle.name` setting, first use the +<> to remove the existing {ilm-init} +policy. See <>. + [discrete] [[change-static-index-setting-for-a-data-stream]] === Change a static index setting for a data stream diff --git a/docs/reference/ilm/set-up-lifecycle-policy.asciidoc b/docs/reference/ilm/set-up-lifecycle-policy.asciidoc index c22135fce8c91..92511ab52cd75 100644 --- a/docs/reference/ilm/set-up-lifecycle-policy.asciidoc +++ b/docs/reference/ilm/set-up-lifecycle-policy.asciidoc @@ -268,3 +268,70 @@ PUT mylogs-pre-ilm*/_settings <1> // TEST[continued] <1> Updates all indices with names that start with `mylogs-pre-ilm` + +[discrete] +[[switch-lifecycle-policies]] +==== Switch lifecycle policies + +To switch an index's lifecycle policy, follow these steps: + +. Remove the existing policy using the <>. +Target a data stream or alias to remove the policies of all its indices. ++ +[source,console] +---- +POST logs-my_app-default/_ilm/remove +---- +// TEST[continued] +// TEST[s/^/PUT _data_stream\/logs-my_app-default\n/] + +. The remove policy API removes all {ilm-init} metadata from the index and +doesn't consider the index's lifecycle status. This can leave indices in an +undesired state. ++ +-- +For example, the <> action temporarily closes an +index before reopening it. Removing an index's {ilm-init} policy during a +`forcemerge` can leave the index closed indefinitely. + +After policy removal, use the <> to check an +index's state . Target a data stream or alias to get the state of all its +indices. + +[source,console] +---- +GET logs-my_app-default +---- +// TEST[continued] + +You can then change the index as needed. For example, you can re-open any +closed indices using the <>. + +[source,console] +---- +POST logs-my_app-default/_open +---- +// TEST[continued] +-- + +. Assign a new policy using the <>. +Target a data stream or alias to assign a policy to all its indices. ++ +-- +WARNING: Don't assign a new policy without first removing the existing policy. +This can cause <> to silently fail. + +[source,console] +---- +PUT logs-my_app-default/_settings +{ + "index": { + "lifecycle": { + "name": "new-lifecycle-policy" + } + } +} +---- +// TEST[continued] +// TEST[s/new-lifecycle-policy/mylogs_policy_existing/] +--