Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Index State Management support #284

Closed
kinoute opened this issue Feb 9, 2023 · 5 comments
Closed

[FEATURE] Index State Management support #284

kinoute opened this issue Feb 9, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@kinoute
Copy link

kinoute commented Feb 9, 2023

Is your feature request related to a problem?

I would like to create/add index policy in the Index State Management but couldn't find a way to do it.

What solution would you like?

Support The index state management to create policies.

What alternatives have you considered?

I tried the official ElasticSearch which supports the feature through the use of a ilmClient instance and the put_lifecycle method. But it doesn't work with OpenSearch because it tries to create policies in /_ilm/policy/abc which doesn't exist in OpenSearch:

no handler found for uri [/_ilm/policy/abc] and method [PUT]',
 'no handler found for uri [/_ilm/policy/abc] and method [PUT]')
@kinoute kinoute added enhancement New feature or request untriaged Need triage labels Feb 9, 2023
@wbeckler
Copy link
Contributor

wbeckler commented Feb 9, 2023

This is a good idea. Most of the plugins are unsupported via methods in the client, so developers end up writing raw curl requests and sending those like this (not in python):

PUT _plugins/_ism/policies/policy_id
{
  "policy": {
    "description": "Example policy.",
    "default_state": "...",
    "states": [...],
    "ism_template": {
      "index_patterns": ["index_name-*"],
      "priority": 100
    }
  }
}

There is a larger question of how to support plugins in clients. In OpenSearch, there is no such thing as an "ilmClient."

I think one of the visions for OpenSearch is to be more extensible and flexible than its predecessor, which means it should be easy to add in this kind of functionality. And we should expect an increasing number of plugins/extensions.

Where do you think this functionality should go for the python client?

@wbeckler wbeckler removed the untriaged Need triage label Feb 9, 2023
@wbeckler
Copy link
Contributor

wbeckler commented Feb 9, 2023

I should also mention that someone started this conversation about how to architect this here: #90

@kinoute
Copy link
Author

kinoute commented Feb 14, 2023

For those who are interested, I forked the ElasticSearch Python library to support the creation of ISM/ILM policies and it works:

https:/kinoute/elasticsearch-py/blob/7.11/elasticsearch/client/ilm.py#L111-130

    def put_lifecycle(self, policy, body=None, params=None, headers=None):
        """
        Creates a lifecycle policy

        `<https://www.elastic.co/guide/en/elasticsearch/reference/7.11/ilm-put-lifecycle.html>`_

        :arg policy: The name of the index lifecycle policy
        :arg body: The lifecycle policy definition to register
        """
        if policy in SKIP_IN_PATH:
            raise ValueError("Empty value passed for a required argument 'policy'.")


        return self.transport.perform_request(
            "PUT",
            _make_path("_plugins", "_ism", "policies", policy),
            params=params,
            headers=headers,
            body=body,
        )

@wbeckler
Copy link
Contributor

Feel free to contribute any code to this repo that you write or find, as long as its license is compatible (e.g., Apache 2.0).

@dblock
Copy link
Member

dblock commented Jul 26, 2023

Closed via #398

@dblock dblock closed this as completed Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants