# Timeout on search

**URL:** <https://discuss.elastic.co/t/timeout-on-search/8327>\
**Category:** Elasticsearch\
**Created:** [July 5, 2012, 3:48pm UTC](https://discuss.elastic.co/t/timeout-on-search/8327 "2012-07-05T15:48:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vik/32/2052_2.png) [@Vik](https://discuss.elastic.co/u/Vik)\
**Post date:** [July 5, 2012, 3:48pm UTC](https://discuss.elastic.co/t/timeout-on-search/8327/1 "2012-07-05T15:48:59Z")

</div>

I am looking to specify a timeout on the search as per the api spec at

[http://www.elasticsearch.org/guide/reference/api/search/request-body.html](http://www.elasticsearch.org/guide/reference/api/search/request-body.html)

timeout "A search timeout, bounding the search request to be executed  
within the specified time value and bail with the hits accumulated up to  
that point when expired. Defaults to no timeout."

So i am assuming this is just a matter of appending the "timeout" param to  
the elastic search url?

[http://localhost:9200/{indexname}/\_search?timeout=5](http://localhost:9200/%7Bindexname%7D/_search?timeout=5)

the spec does not specify what the parameter signifies as in is it  
milliseconds/seconds os how does this need to be specified?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [July 5, 2012, 4:12pm UTC](https://discuss.elastic.co/t/timeout-on-search/8327/2 "2012-07-05T16:12:05Z")

</div>

Looking at the source code, the timeout value should be in milliseconds:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java#L201](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java#L201)  
[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/unit/TimeValue.java#L228](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/unit/TimeValue.java#L228)

--  
Ivan

On Thu, Jul 5, 2012 at 8:48 AM, Vik [vmnadig@gmail.com](mailto:vmnadig@gmail.com) wrote:

> I am looking to specify a timeout on the search as per the api spec at
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/request-body.html)
> 
> timeout "A search timeout, bounding the search request to be executed within  
> the specified time value and bail with the hits accumulated up to that point  
> when expired. Defaults to no timeout."
> 
> So i am assuming this is just a matter of appending the "timeout" param to  
> the Elasticsearch url?
> 
> [http://localhost:9200/{indexname}/\_search?timeout=5](http://localhost:9200/%7Bindexname%7D/_search?timeout=5)
> 
> the spec does not specify what the parameter signifies as in is it  
> milliseconds/seconds os how does this need to be specified?

---

<div class="post-metadata">

**Author:** ![anon44344346](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@anon44344346](https://discuss.elastic.co/u/anon44344346)\
**Post date:** [July 17, 2012, 6:48pm UTC](https://discuss.elastic.co/t/timeout-on-search/8327/3 "2012-07-17T18:48:43Z")

</div>

Ok, I've tried it just like Vik said, and got no luck so far:

curl -XGET '[http://localhost:9200/book\_store/\_search?timeout=40ms&pretty=1](http://localhost:9200/book_store/_search?timeout=40ms&pretty=1)'  
-d '  
{  
"query": {  
"fuzzy": {  
"\_all": "dostoyefsk"  
}  
}  
}'

got the answer

{  
"took" : 496,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},...

The answer takes about 500ms, and it doesn't seem to care I specified  
"50ms" for the timeout.  
Is this because of the "fuzzy" search? Or is it because the specified  
timeout is way too small?

txs

On Thursday, July 5, 2012 12:12:05 PM UTC-4, Ivan Brusic wrote:

> Looking at the source code, the timeout value should be in milliseconds:
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java#L201](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java#L201)
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/unit/TimeValue.java#L228](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/unit/TimeValue.java#L228)
> 
> --  
> Ivan
> 
> On Thu, Jul 5, 2012 at 8:48 AM, Vik wrote:
> 
> > I am looking to specify a timeout on the search as per the api spec at
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/request-body.html)
> 
> > timeout "A search timeout, bounding the search request to be executed  
> > within  
> > the specified time value and bail with the hits accumulated up to that  
> > point  
> > when expired. Defaults to no timeout."
> > 
> > So i am assuming this is just a matter of appending the "timeout" param  
> > to  
> > the Elasticsearch url?
> > 
> > [http://localhost:9200/{indexname}/\_search?timeout=5](http://localhost:9200/%7Bindexname%7D/_search?timeout=5)
> > 
> > the spec does not specify what the parameter signifies as in is it  
> > milliseconds/seconds os how does this need to be specified?

---

<div class="post-metadata">

**Author:** ![pku](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@pku](https://discuss.elastic.co/u/pku)\
**Post date:** [September 20, 2016, 10:09pm UTC](https://discuss.elastic.co/t/timeout-on-search/8327/4 "2016-09-20T22:09:31Z")

</div>

I am facing the same issue and wondering if you figured out the reason or solution for this issue.

---

<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 5, 2017, 10:18pm UTC](https://discuss.elastic.co/t/timeout-on-search/8327/5 "2017-07-05T22:18:42Z")

</div>


