Why delete document by id not support index wildcard

Recently, I found that the delete document by id have to through delete by query.

POST /blog-*/messages/_delete_by_query?pretty
{
  "query": {
    "match": {
      "_id": "N1H$K4Xtsra"
    }
  }
}

Is there any plan to add support for wildcard for delete by id?

DELETE /blog-*/messages/N1H$K4Xtsra

Such a request is supposed to do directly to one specific shard to DELETE a single document.

For the same reason as you can't do PUT test*/doc/1, you can't do a DELETE test*/doc/1.

When you mean to remove multiple documents, elasticsearch needs first to locate where the documents are (by running a query) and then elasticsearch needs to delete each of them, one by one.

This is what a DELETE BY QUERY is exactly doing behind the scene:

  • search
  • bulk delete

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.