How to auto delete data older than 2 month or 30 days from elastcisearch index?

Note: I am not using date in index name like index -yyyy-mm .
any method to do this i am using python Elasticsearch client to store data in es database.

The only bilt-in way to manage retention of data in Elasticsearch is ILM, and this relies on time-based indices (by name as you outlined or rollover) being used.

If you have a single index you need to delete data using delete-by-query and you need to periodically schedule these operations yourself.

in my Elasticsearch index one data is date/time and timestamp . So how to do query and delete data older than X days?

Use the delete by query API with a date range filter.

I want to automate this task using pyhton script. how to do it?

Look at the links I provided and write a Python script that periodically uses that API, e.g. by triggering it via cron.

1 Like

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