Elasticsearch 6.3 - SearchRequest timeout value in the SearchSource not honored

Referring this API doc page:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.3/java-rest-high-search.html

 sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS)); 

"Set an optional timeout that controls how long the search is allowed to take."

When I set this value to be 1 millisecond or 1 nanosecond. The search response I got is still with the timedOut flag as false, though the time taken number was 29 (not sure about the unit but guessing it millisecond)

Here is one response I got when I set the timeOut value in the request as 1 nanosecond:

{"took":29,"timed_out":false,"_shards":{"total":1110,"successful":1110,"skipped":869,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

The reason I am doing this testing is sometimes we are seeing the response has "timed_out" flag as "true" in the response and we are trying to see if we could adjust the timeOut value in the search request to reduce that. But first of all is to confirm if those 2 flags are related and it seems they are not.

Can someone clarify if those two are truly unrelated and how the timedOut flag in the response is set to true?

1 Like

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