Lifecycle management abstraction for ILM (Elasticsearch) and ISM (OpenSearch).
This module provides transformation between Elasticsearch's ILM (Index Lifecycle Management) and OpenSearch's ISM (Index State Management) policy formats, allowing the same policy API to work transparently with both engines.
Lifecycle management abstraction for ILM (Elasticsearch) and ISM (OpenSearch). This module provides transformation between Elasticsearch's ILM (Index Lifecycle Management) and OpenSearch's ISM (Index State Management) policy formats, allowing the same policy API to work transparently with both engines.
(create-policy! {:keys [uri version engine request-fn] :as conn}
policy-name
policy)Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str policy :- Policy]
Create a lifecycle management policy.
The policy parameter should be in ILM format. It will be automatically transformed to ISM format if connecting to OpenSearch.
If the policy already exists (409 conflict), this function will automatically update the existing policy using update-policy!.
Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str policy :- Policy]
Create a lifecycle management policy.
- For Elasticsearch: Creates an ILM policy
- For OpenSearch: Creates an ISM policy (automatically transforms ILM if needed)
The policy parameter should be in ILM format. It will be automatically
transformed to ISM format if connecting to OpenSearch.
If the policy already exists (409 conflict), this function will automatically
update the existing policy using update-policy!.(delete-policy! {:keys [uri version engine request-fn] :as conn} policy-name)Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str]
Delete a lifecycle management policy. Works with both Elasticsearch ILM and OpenSearch ISM.
Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str]
Delete a lifecycle management policy.
Works with both Elasticsearch ILM and OpenSearch ISM.(get-policy {:keys [engine] :as conn} policy-name)Inputs: [{:keys [engine], :as conn} :- ESConn policy-name :- s/Str]
Get a lifecycle management policy. Works with both Elasticsearch ILM and OpenSearch ISM. Returns the policy in its native format (ILM or ISM).
Inputs: [{:keys [engine], :as conn} :- ESConn policy-name :- s/Str]
Get a lifecycle management policy.
Works with both Elasticsearch ILM and OpenSearch ISM.
Returns the policy in its native format (ILM or ISM).(get-policy-raw {:keys [uri version engine request-fn] :as conn} policy-name)Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str]
Get a lifecycle management policy with full response metadata. Returns the raw response including _seq_no and _primary_term for OpenSearch. Use this when you need version info for updates.
Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str]
Get a lifecycle management policy with full response metadata.
Returns the raw response including _seq_no and _primary_term for OpenSearch.
Use this when you need version info for updates.Elasticsearch ILM policy structure
Elasticsearch ILM policy structure
OpenSearch ISM transition structure
OpenSearch ISM transition structure
(normalize-policy policy target-engine)Normalize a policy for the target engine. If the policy is already in the target format, return as-is. Otherwise, transform it.
Normalize a policy for the target engine. If the policy is already in the target format, return as-is. Otherwise, transform it.
(policy-uri uri policy-name)(policy-uri uri policy-name engine)Inputs: ([uri :- s/Str policy-name :- s/Str engine :- s/Keyword] [uri :- s/Str policy-name :- s/Str]) Returns: s/Str
Make a policy URI from a host, policy name, and engine type.
Inputs: ([uri :- s/Str policy-name :- s/Str engine :- s/Keyword] [uri :- s/Str policy-name :- s/Str]) Returns: s/Str Make a policy URI from a host, policy name, and engine type. - Elasticsearch uses _ilm/policy - OpenSearch uses _plugins/_ism/policies
(transform-ilm-to-ism ilm-policy)Inputs: [ilm-policy :- ILMPolicy] Returns: ISMPolicy
Transform Elasticsearch ILM policy to OpenSearch ISM policy.
ILM uses phases (hot, warm, cold, delete) with actions. ISM uses states with actions and transitions between states.
Example: (transform-ilm-to-ism {:phases {:hot {:actions {:rollover {:max_docs 100000}}} :delete {:min_age "30d" :actions {:delete {}}}}})
Inputs: [ilm-policy :- ILMPolicy]
Returns: ISMPolicy
Transform Elasticsearch ILM policy to OpenSearch ISM policy.
ILM uses phases (hot, warm, cold, delete) with actions.
ISM uses states with actions and transitions between states.
Example:
(transform-ilm-to-ism
{:phases {:hot {:actions {:rollover {:max_docs 100000}}}
:delete {:min_age "30d" :actions {:delete {}}}}})(transform-ism-to-ilm ism-policy)Inputs: [ism-policy :- ISMPolicy] Returns: ILMPolicy
Transform OpenSearch ISM policy to Elasticsearch ILM policy.
This is a best-effort transformation as ISM is more flexible than ILM. Some ISM features may not have direct ILM equivalents.
Inputs: [ism-policy :- ISMPolicy] Returns: ILMPolicy Transform OpenSearch ISM policy to Elasticsearch ILM policy. This is a best-effort transformation as ISM is more flexible than ILM. Some ISM features may not have direct ILM equivalents.
(update-policy! {:keys [uri version engine request-fn] :as conn}
policy-name
policy)Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str policy :- Policy]
Update an existing lifecycle management policy.
The policy parameter should be in ILM format. It will be automatically transformed to ISM format if connecting to OpenSearch.
For OpenSearch, this function first retrieves the current policy to get _seq_no and _primary_term, then performs a conditional update.
Inputs: [{:keys [uri version engine request-fn], :as conn} :- ESConn policy-name :- s/Str policy :- Policy]
Update an existing lifecycle management policy.
- For Elasticsearch: Updates an ILM policy (simple PUT, no version control needed)
- For OpenSearch: Updates an ISM policy using seq_no and primary_term for optimistic locking
The policy parameter should be in ILM format. It will be automatically
transformed to ISM format if connecting to OpenSearch.
For OpenSearch, this function first retrieves the current policy to get
_seq_no and _primary_term, then performs a conditional update.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |