I have an index called "animals" in elasticsearch. That contains several documents of type "dogs". I want to delete all "dogs" documents in "animals" index. I am using python elasticsearch package. My python code is as follows:
connection = Elasticsearch([{"host": "myhost", "port": "myport" } ])
body = {} # What should I put in the body???
connection.bulk(body, index="animals", doc_type="dogs", ignore=[400, 404])
Here I don't know what do I need to put in the body
. Can anyone help me out?
Bulk method is defined at https://github.com/elastic/elasticsearch-py/blob/master/elasticsearch/client/ init .py#L1002
There is no api in elasticsearch-py
to delete all documents of a type. This is because Elasticsearch 2.x onwards there is no api to delete a type
. From the documentation
In 1.x it was possible to delete a type mapping, along with all of the documents of that type, using the delete mapping API. This is no longer supported, because remnants of the fields in the type could remain in the index, causing corruption later on.
Instead, if you need to delete a type mapping, you should reindex to a new index which does not contain the mapping. If you just need to delete the documents that belong to that type, then use the delete-by-query plugin instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.