# Question about query timeout (both in URI and in query body)

**URL:** <https://discuss.elastic.co/t/question-about-query-timeout-both-in-uri-and-in-query-body/9094>\
**Category:** Elasticsearch\
**Created:** [September 21, 2012, 10:17am UTC](https://discuss.elastic.co/t/question-about-query-timeout-both-in-uri-and-in-query-body/9094 "2012-09-21T10:17:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [September 21, 2012, 10:17am UTC](https://discuss.elastic.co/t/question-about-query-timeout-both-in-uri-and-in-query-body/9094/1 "2012-09-21T10:17:52Z")

</div>

Hello!

I have a question about the timeout, I hope someone can help me. I  
tried to use query timeout, for example like this:

curl -XGET 'localhost:9200/\_search' -d '{"timeout" : "10ms", "query": {"term" : { "\_all" : "apple" }}}'

or

curl -XGET 'localhost:9200/\_search?q=apple&timeout=10ms'

The above queries are run against 20 shards and each time the overall  
time the query is executed is far above the provided timeout value,  
even if we count 10ms \* 20 shards where the total time would give  
200ms and I sometimes see query execution time being longer than  
1000ms.

What I'm wondering if I'm missing something how timeout works ? Can  
anyone share some thoughts or experiences about timeout ?

--  
Regards,  
Rafał Kuć  
Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - ElasticSearch

--

---

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [September 22, 2012, 2:38am UTC](https://discuss.elastic.co/t/question-about-query-timeout-both-in-uri-and-in-query-body/9094/2 "2012-09-22T02:38:47Z")

</div>

This question is similar to  
[https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/timeout$20not$20working/elasticsearch/AjpmlShg8jc/rn5oPMqecuUJ](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/timeout$20not$20working/elasticsearch/AjpmlShg8jc/rn5oPMqecuUJ)  
which got no answers.

Is it the case that the timeout value applies _only_ to the actual query  
_execution_ at Lucene level?

As in:

> <https://github.com/elastic/elasticsearch/blob/348117c823dde61490fb90389bddae3a0778e827/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java#L83>

## Thanks, Otis

Search Analytics - [Cloud Monitoring Tools & Services | Sematext](http://sematext.com/search-analytics/index.html)  
Performance Monitoring - [Sematext Monitoring | Infrastructure Monitoring Service](http://sematext.com/spm/index.html)

On Friday, September 21, 2012 6:18:09 AM UTC-4, Rafał Kuć wrote:

> Hello!
> 
> I have a question about the timeout, I hope someone can help me. I  
> tried to use query timeout, for example like this:
> 
> curl -XGET 'localhost:9200/\_search' -d '{"timeout" : "10ms", "query":  
> {"term" : { "\_all" : "apple" }}}'
> 
> or
> 
> curl -XGET 'localhost:9200/\_search?q=apple&timeout=10ms'
> 
> The above queries are run against 20 shards and each time the overall  
> time the query is executed is far above the provided timeout value,  
> even if we count 10ms \* 20 shards where the total time would give  
> 200ms and I sometimes see query execution time being longer than  
> 1000ms.
> 
> What I'm wondering if I'm missing something how timeout works ? Can  
> anyone share some thoughts or experiences about timeout ?
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch -  
> Elasticsearch

--

---

<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 6, 2017, 3:11am UTC](https://discuss.elastic.co/t/question-about-query-timeout-both-in-uri-and-in-query-body/9094/3 "2017-07-06T03:11:48Z")

</div>


