# How to cancel search using the Task Management API

**URL:** <https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842>\
**Category:** Elasticsearch\
**Created:** [February 3, 2017, 11:59am UTC](https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842 "2017-02-03T11:59:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfwm2](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@jfwm2](https://discuss.elastic.co/u/jfwm2)\
**Post date:** [February 3, 2017, 11:59am UTC](https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842/1 "2017-02-03T11:59:40Z")

</div>

I would like to cancel a long running search tasks using the Task Management API, but when I try to cancel such a task, I obtain the following error message:  
{  
"node\_failures" : [ {  
"type" : "failed\_node\_exception",  
"reason" : "Failed node [EEXZOO90RNGXkReo\_sXfig]",  
"caused\_by" : {  
"type" : "resource\_not\_found\_exception",  
"reason" : "task [EEXZOO90RNGXkReo\_sXfig:255615824] doesn't support cancellation"  
}  
} ],  
"nodes" : { }  
}  
Is there currently a way to cancel such a task?

Any help would be much appreciated.  
Thanks  
jfwm

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [February 3, 2017, 10:19pm UTC](https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842/2 "2017-02-03T22:19:23Z")

</div>

~~Search does not currently support cancellation. I believe the only tasks supporting cancellation at the moment are Reindex and Delete-By-Query. We'd like to have cancellable search in the future, but because the task management framework is still very new, it may be a while before that functionality is integrated everywhere.~~

Edit: See below, search cancellation is possible! 🙂

---

<div class="post-metadata">

**Author:** ![jfwm2](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@jfwm2](https://discuss.elastic.co/u/jfwm2)\
**Post date:** [February 6, 2017, 9:36am UTC](https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842/3 "2017-02-06T09:36:55Z")

</div>

Thanks for your answer, we are very interested to have this feature. Therefore I believe we are going to dive into the code to see how we could implemented this functionality. Any pointers?

---

<div class="post-metadata">

**Author:** ![jfwm2](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@jfwm2](https://discuss.elastic.co/u/jfwm2)\
**Post date:** [February 6, 2017, 10:54am UTC](https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842/4 "2017-02-06T10:54:14Z")

</div>

It seems that the Search cancellation feature is available in 5.x (starting in 5.1): [https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search.html#global-search-cancellation](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search.html#global-search-cancellation)

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [February 6, 2017, 1:09pm UTC](https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842/5 "2017-02-06T13:09:29Z")

</div>

Oops, you're absolutely right! Sorry about that, it's sometimes hard to keep up with all the changes in ES, even when you work on the software 🙂

I'll strike through my answer above so future readers don't get confused

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 6, 2017, 1:10pm UTC](https://discuss.elastic.co/t/how-to-cancel-search-using-the-task-management-api/73842/6 "2017-03-06T13:10:00Z")

</div>

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