Elasticsearch inaccurate shard state when timed_out is true

Hey there,

I have an index with 40 shards and I use the timeout feature with my search query. As per the documentation, if request timeout before it completes search on all shards, it will return whatever the results other shards return. But _shard state always returns me 40 shards successful and 0 failed and 0 skipped.

Can anyone suggest how should I make a request so, I will either get correct stats or will have timed_out flag false and get correct/accurate results with timeout?

If you're getting results from all shards then doesn't that imply it's not timing out?

@warkolm Thanks for the reply. In my case, I know the actual count and when the timed_out flag is true, the total hits count is not accurate, and also at the same time, the shards' stats tells me all shards are successful.

  "took" : 11,
  "timed_out" : true,
  "_shards" : {
    "total" : 40,
    "successful" : 40,
    "skipped" : 0,
    "failed" : 0
  "hits" : {
    "total" : {
      "value" : 2229157, // inaccurate value
      "relation" : "eq"
    "max_score" : null,
    "hits" : [ ]

How do you know it's inaccurate?