What would be the equivalent operation in elasticsearchfor doing:
TRUNCATE mytable
The index that I want to truncate is called 'myindex'. In other words, after the operation, I want to have zero documents in the index 'myindex'.
You would need to delete the index and then recreate it. While this will require you to setup your mapping again.
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html
There are other options such as deleting by query, but this will mark records as deleted in the lucene index and, while merged out over time, will not free up space.
It seems that the easiest way to do this would be to delete the actual index and re-create it afterwards. For example:
def clear_index(self, index=None):
'''
This will remove all objects from the index
by deleting the index and re-creating it.
'''
index = index or self.index
self.delete_index(index=index) # self.es.indices.delete(index)
self.create_index(index=index) # self.es.indices.create(index=index, body=body)