# Difference between the timeout param mentioned in query-string parameters and request body

**URL:** <https://discuss.elastic.co/t/difference-between-the-timeout-param-mentioned-in-query-string-parameters-and-request-body/208217>\
**Category:** Elasticsearch\
**Created:** [November 17, 2019, 11:00am UTC](https://discuss.elastic.co/t/difference-between-the-timeout-param-mentioned-in-query-string-parameters-and-request-body/208217 "2019-11-17T11:00:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitmbm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amitmbm/32/102111_2.png) [@amitmbm](https://discuss.elastic.co/u/amitmbm)\
**Post date:** [November 17, 2019, 11:00am UTC](https://discuss.elastic.co/t/difference-between-the-timeout-param-mentioned-in-query-string-parameters-and-request-body/208217/1 "2019-11-17T11:00:23Z")

</div>

I am trying to understand the ES timeout and found different resources which talked about different things.

## **Timeout param in query String**

As per [this](https://www.elastic.co/guide/en/elasticsearch/guide/current/_search_options.html#_timeout_2) ES doc:

> The timeout parameter tells shards how long they are allowed to process data before returning a response to the coordinating node. If there was not enough time to process all data, results for this shard will be partial, even possibly empty.

And in case of timeout, ES response metadata `timed_out` would be true, also it would list the no of failed shards, But **when I specify this timeout to a ver low value like `5ms` or `2ms` in my query string param for a `match_all` query on big index** , Sometime

1. My response have this very rare `timed_out` true and number of failed shards are always 0.
2. `took` in my response is always very high than the timeout but still most of my response contains `timed_out` false.

Both of these contradicts to what is mentioned in ES docs.

## **Timeout param in search JSON**

I also tried to give the `timeout` param as part of search JSON mentioned in [this](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-body.html#_parameters_4), but observed the same points mentioned earlier, **so are these both same or they are different and meant for different use case?**

PS: Below ES point from same [article](https://www.elastic.co/guide/en/elasticsearch/guide/current/_search_options.html#_timeout_2), is what I am unable to digest, and are my observations due to below fact?

**Because the time is once per document, a very long query can execute on a single document and it won’t timeout until the next document is evaluated. This also means poorly written scripts (e.g. ones with infinite loops) will be allowed to execute forever.**

---

<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:** [December 15, 2019, 11:00am UTC](https://discuss.elastic.co/t/difference-between-the-timeout-param-mentioned-in-query-string-parameters-and-request-body/208217/2 "2019-12-15T11:00:23Z")

</div>

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