Kyle
Kyle

Reputation: 162

How do you delete a completed task for a Delete-By-Query in Elasticsearch 5.6?

I currently have a completed delete-by-query task:

curl -XGET "http://localhost/_tasks/x0i0D1FdEs-M29DDewnPwkg:257894116" {"completed":true,"task":{"node":"x0i0D1FdEs-M29DDewnPwkg","id":257894116,"type":"transport","action":"indices:data/write/delete/byquery","status":{"total":2650620,"updated":0,"created":0,"deleted":2650620,"batches":2651,"version_conflicts":0,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0},"description":"delete-by-query [testIndex]","start_time_in_millis":1509555456799,"running_time_in_nanos":386994755521,"cancellable":true},"response":{"took":386993,"timed_out":false,"total":2650620,"updated":0,"created":0,"deleted":2650620,"batches":2651,"version_conflicts":0,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[]}}%

The delete-by-query documentation for Tasks says the following:

If the request contains wait_for_completion=false then Elasticsearch will perform some preflight checks, launch the request, and then return a task which can be used with Tasks APIs to cancel or get the status of the task. Elasticsearch will also create a record of this task as a document at .tasks/task/${taskId}. This is yours to keep or remove as you see fit. When you are done with it, delete it so Elasticsearch can reclaim the space it uses.

Yet when I run the following:

curl -XDELETE "http:localhost/_tasks/x0i0D1FdEs-M29DDewnPwkg:257894116"

I get

No handler found for uri [/_tasks/x0i0D1FdEs-M29DDewnPwkg:257894116] and method [DELETE]%

Upvotes: 2

Views: 1998

Answers (2)

Jinggang
Jinggang

Reputation: 431

@Val 's answer is right. I would like to also mention, you can only delete a task with wait_for_deletion == false. Based on what I tried, if you have wait_for_deletion == true when you send you delete-by-query task, that task is only "in-memory". After it's completed, it will not be stored in .task system index. You don't need to delete anything, and trying to delete it will give you a "resouce_not_found_exception" response.

Upvotes: 1

Val
Val

Reputation: 217564

You need to delete the task with the following command

curl -XDELETE "http:localhost/.tasks/task/x0i0D1FdEs-M29DDewnPwkg:257894116"

Upvotes: 3

Related Questions