Elastic Timeout not working

When I am passing the timeout value 1ms in the request, still the result is coming with took value being more than 1ms.
How does this timeout value work?
Request -

GET dco-preview/_search
{
  "timeout": "10ms", 
  "query": {
    "match_all": {}
  }
}

Here the timeout is set to 10ms, but the response is taking more time, and elastic is not breaking the connection.

{
  "took" : 153,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : 1.0,
    "hits" : [
      {....}
]}}

Elasticsearch only checks for a timed-out request at certain points during execution of the query, and only covers certain aspects of the execution. It also doesn't account for network delays etc. If you need a hard timeout in your application, you need to do it on the client side.

1 Like

1ms seems way too small anyway, you should really be increasing that.

1 Like

This is just to test that, elastic will break the request when 1 ms is reached.

I don't know the technical details of how the timeout is implemented, but if it's anything else like the rest of the design of Elasticsearch I would be very surprised if it worked and you would be better off using a more realistic timeout period.

1 Like

Regardless of the timeout period, there are some things that Elasticsearch itself doesn't count. That might be by design (e.g. some aspects of the search execution are deliberately excluded) or because there is no way it can measure them (e.g. network delays on the way to the client are invisible to Elasticsearch). They need client-side timeouts.

1 Like

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