Elasticsearch : How to delete an Index using python
From the docs, use this notation:
from elasticsearch import Elasticsearch
es = Elasticsearch()
es.indices.delete(index='test-index', ignore=[400, 404])
If you have a document object (model) and you're using elasticsearch-dsl, specially with Python-3.X you can directly call the delete
method of your model's _index
attribute.
ClassName._index.delete()
Also as it's stated in documentation:
The
_index
attribute is also home to the load_mappings method which will update the mapping on the Index from elasticsearch. This is very useful if you use dynamic mappings and want the class to be aware of those fields (for example if you wish the Date fields to be properly (de)serialized):Post._index.load_mappings()