Creating an ILM policy using python

I have been trying to create an ILM policy using the python client. But I get an error when running the python script.

This is my code:

from datetime import datetime
from elasticsearch import Elasticsearch
from elasticsearch.Elasticsearch.client import ILMClient

es = Elasticsearch()
es_ilm = IlmClient(es)
**---- more lines of code ----**

But I get the following error:

C:\elasticsearchpython\datastreamilm>python create_policy.py
Traceback (most recent call last):
  File "C:\elasticsearchpython\datastreamilm\create_policy.py", line 3, in <module>
    from elasticsearch.Elasticsearch.client import ILMClient
ModuleNotFoundError: No module named 'elasticsearch.Elasticsearch'

How do you import the ILMClient into the python script? Also, do I need to download and install anything other than the Elasticsearch module?

Welcome!

Which client version are you using?

I'm not super familiar with python but don't you have a typo between IlmClient and ILMClient.

thank you so much. that was the mistake.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.