# Why \_msearch request isn't cancellable(=false)?

**URL:** <https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893>\
**Category:** Elasticsearch\
**Created:** [June 5, 2020, 6:45am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893 "2020-06-05T06:45:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul\_yadav1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_yadav1/32/69763_2.png) [@rahul\_yadav1](https://discuss.elastic.co/u/rahul_yadav1)\
**Post date:** [June 5, 2020, 6:45am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/1 "2020-06-05T06:45:17Z")

</div>

In ES-7.4.2, search request is cancellable(=true) but \_msearch request isn't. What's the idea behind it ??

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [June 5, 2020, 7:08am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/2 "2020-06-05T07:08:29Z")

</div>

It's in progress for a future version (see [https://github.com/elastic/elasticsearch/pull/44494](https://github.com/elastic/elasticsearch/pull/44494)) but needed some changes to how task cancellation was implemented internally first.

---

<div class="post-metadata">

**Author:** ![rahul\_yadav1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_yadav1/32/69763_2.png) [@rahul\_yadav1](https://discuss.elastic.co/u/rahul_yadav1)\
**Post date:** [June 5, 2020, 8:41am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/3 "2020-06-05T08:41:22Z")

</div>

Thanks for quick response. I have seen these changes. I wanted to know by making these changes , Are we able to cancel msearch request ??  
Because, I am facing some problem in it. When I am cancelling the task by using taskid, It's show 'resource not found' exception. and Most of the time, It isn't showing under running tasks (not able to get taskid) while msearch request is still pending.  
But in search request, I am not facing such issue .

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [June 5, 2020, 9:55am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/4 "2020-06-05T09:55:54Z")

</div>

> [@rahul\_yadav1](#):
>
> I wanted to know by making these changes , Are we able to cancel msearch request ??

Yes, multi search tasks will be cancellable when the "[make multi search tasks cancellable](https://github.com/elastic/elasticsearch/pull/44494)" issue is completed.

> [@rahul\_yadav1](#):
>
> Because, I am facing some problem in it. When I am cancelling the task by using taskid...

Yes, multi-search requests are not yet cancellable so it is to be expected that cancelling them doesn't work.

FWIW the preferred way to cancel a search request is simply to close the client connection, not to use the task management API.

---

<div class="post-metadata">

**Author:** ![rahul\_yadav1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_yadav1/32/69763_2.png) [@rahul\_yadav1](https://discuss.elastic.co/u/rahul_yadav1)\
**Post date:** [June 5, 2020, 1:41pm UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/5 "2020-06-05T13:41:42Z")

</div>

I am a little bit confused here.

 ![r_query](https://us1.discourse-cdn.com/elastic/original/3X/7/c/7c6a7b7e964b2f035db42066c74500eac28d75a6.png)

As in the image, We have 'action = search' and 'cancellable = true' . Does this not mean, We can cancel the search request by using taskid ??  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html)

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [June 5, 2020, 3:35pm UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/6 "2020-06-05T15:35:01Z")

</div>

Sorry I don't understand the question. Cancellable tasks can be cancelled, but msearch requests aren't cancellable?

---

<div class="post-metadata">

**Author:** ![rahul\_yadav1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_yadav1/32/69763_2.png) [@rahul\_yadav1](https://discuss.elastic.co/u/rahul_yadav1)\
**Post date:** [June 6, 2020, 5:55am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/7 "2020-06-06T05:55:19Z")

</div>

okay, let me explain whole scenario.  
I am using Multi Search API(\_msearch) for query that is taking long time to execute. I want to cancel that query. [I have made multi search tasks cancellable(=true)](https://github.com/elastic/elasticsearch/pull/44494).  
Can we cancel that query through task management api??

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 6, 2020, 8:18am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/8 "2020-06-06T08:18:27Z")

</div>

You can not cancel it at the moment. Based on the release tags on the pull request David linked to it will be possible when version 7.9 comes out, so you would need to upgrade at that point.

---

<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:** [July 4, 2020, 8:18am UTC](https://discuss.elastic.co/t/why-msearch-request-isnt-cancellable-false/235893/9 "2020-07-04T08:18:27Z")

</div>

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