Unpredictable work of terminate_after

Hi team,
I have an index with 4 billion docs, 200 shards, I want to use terminate_after=500000 if I correctly understood request must terminate after 100kk docs, when the count of docs is more than 100kk it's working fine, but when 93-99 kk request terminates too, can you give me an advice what I am doing wrong? Or is it a bug? I use Elasticsearch 7.10.0.

{
	"query": {
		"bool": {
			"should": [
				{
					"match": {
						"name": {
							"boost": 1000,
							"query": "g"
						}
					}
				},
				{
					"prefix": {
						"name_full_reverse": {
							"boost": 100,
							"value": "g"
						}
					}
				},
				{
					"multi_match": {
						"fields": [],
						"query": "g"
					}
				}
			]
		}
	}
}

/_count?terminate_after=500000
{
  "terminated_early": true,
  "count": 93705326,
  "_shards": {
    "total": 200,
    "successful": 200,
    "skipped": 0,
    "failed": 0
  }
}

/_count
{
  "count": 98221798,
  "_shards": {
    "total": 200,
    "successful": 200,
    "skipped": 0,
    "failed": 0
  }
}

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