How to delete an Elasticsearch Index using Python?

For ES 8+ use:

from elasticsearch import Elasticsearch
es = Elasticsearch()

es.options(ignore_status=[400,404]).indices.delete(index='test-index')

For older versions use this notation:

from elasticsearch import Elasticsearch
es = Elasticsearch()

es.indices.delete(index='test-index', ignore=[400, 404])

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)