# How timeout control work

**URL:** <https://discuss.elastic.co/t/how-timeout-control-work/226318>\
**Category:** Elasticsearch\
**Created:** [April 3, 2020, 4:48am UTC](https://discuss.elastic.co/t/how-timeout-control-work/226318 "2020-04-03T04:48:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NashMiao](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@NashMiao](https://discuss.elastic.co/u/NashMiao)\
**Post date:** [April 3, 2020, 4:48am UTC](https://discuss.elastic.co/t/how-timeout-control-work/226318/1 "2020-04-03T04:48:51Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/b/e/be39c8d7233a022a2224c4da0f5eb0bcd58f99f4.png)

I add timeout param in search body, then the response shows this query is timeout, took 233 ms. I'm wondering about whether the timeout control did work.

I Javadoc, it describes this param as a time limiter in searching:

```java
/**
 * An optional timeout to control how long search is allowed to take.
 */
public SearchSourceBuilder timeout(TimeValue timeout) {
    this.timeout = timeout;
    return this;
}

```

If the timeout limit work, whether the response will something like following:

```java
  "took" : 200,
  "timed_out" : true

```

I my mind, the `took` shows the actual time this searching spend. therefore, If the timeout param work, why `took > timeout` is allowed?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 3, 2020, 2:04pm UTC](https://discuss.elastic.co/t/how-timeout-control-work/226318/2 "2020-04-03T14:04:15Z")

</div>

took is measured when the request comes into the coordinating node, where the timeout value is only applicable for search, not for the fetch phase for example. So there are some additional tasks that are not the pure search, that are done as well.

hope that helps!

---

<div class="post-metadata">

**Author:** ![NashMiao](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@NashMiao](https://discuss.elastic.co/u/NashMiao)\
**Post date:** [April 7, 2020, 5:52am UTC](https://discuss.elastic.co/t/how-timeout-control-work/226318/3 "2020-04-07T05:52:59Z")

</div>

Thanks!

---

<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:** [May 5, 2020, 5:53am UTC](https://discuss.elastic.co/t/how-timeout-control-work/226318/4 "2020-05-05T05:53:11Z")

</div>

Closed on May 5, 2020, 5:53am UTC

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