Elasticsearch delete across all indexes and types Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Elasticsearch delete across all indexes and types without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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.

We are here to answer your question about Elasticsearch delete across all indexes and types - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji