Elasticsearch delete across all indexes and types

I have a Java application that is using the elasticsearch jar to interface with an elasticsearch client.

What I would like to do is delete something from Elastricsearch when I only know the ID. So, I do not know the index OR type. How can I do this?

I would think doing ...prepareDelete("_all","_all",<id>) or ...prepareDelete("*","*",<id>) would work, but neither are supported in Elasticsearch.

The only way I can think of doing this is to iterate over all indexes and types and delete each one with that ID, but that sounds a little inefficient if Elasticsearch already provides this functionality.

Answer

In ES 1.7 one can still do:

DELETE /_all/_query?q=_id:123

as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html, but in 2.0 it will be removed.

Leave a Reply

Your email address will not be published. Required fields are marked *