In short, normal search hits < scroll slice 1 hits + scroll slice 2 hits
When I add up sliced scroll hits, it is more than total no of documents returned from single search.
Normal search query
GET index*/_search
{
"track_total_hits": true,
"sort": [
{
"@timestamp": {
"order": "asc",
"unmapped_type": "boolean"
}
}
],
"_source": false,
"query": {
"bool": {
"must": [],
"filter": [
{
"range": {
"@timestamp": {
"format": "strict_date_optional_time",
"gte": "2022-07-31T18:30:00.000Z",
"lte": "2022-08-30T18:30:00.000Z"
}
}
}
.....
Normal Search Response:
{
"took" : 1055,
"timed_out" : false,
"_shards" : {
"total" : 455,
"successful" : 455,
"skipped" : 290,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 435743,
"relation" : "eq"
},
"max_score" : null,
Slice 1
GET index*/_search
{
"slice": {
"id": 0,
"max": 2
},
"track_total_hits": true,
"sort": [
{
"@timestamp": {
"order": "asc",
"unmapped_type": "boolean"
}
}
],
"_source": false,
"query": {
"bool": {
"must": [],
"filter": [
{
"range": {
"@timestamp": {
"format": "strict_date_optional_time",
"gte": "2022-07-31T18:30:00.000Z",
"lte": "2022-08-30T18:30:00.000Z"
}
}
}
.....
Slice 1 Response:
"_shards" : {
"total" : 455,
"successful" : 455,
"skipped" : 290,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 213954,
"relation" : "eq"
},
"max_score" : null,
Slice 2
GET index*/_search
{
"slice": {
"id": 1,
"max": 2
},
"track_total_hits": true,
"sort": [
{
"@timestamp": {
"order": "asc",
"unmapped_type": "boolean"
}
}
],
"_source": false,
"query": {
"bool": {
"must": [],
"filter": [
{
"range": {
"@timestamp": {
"format": "strict_date_optional_time",
"gte": "2022-07-31T18:30:00.000Z",
"lte": "2022-08-30T18:30:00.000Z"
}
}
}
.....
Slice 2 Response:
"_shards" : {
"total" : 455,
"successful" : 455,
"skipped" : 292,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 221884,
"relation" : "eq"
},
"max_score" : null,
So as we can see,
total hits for slices = 213954 + 221884 = 435838
which is greater than 435743
(hits for normal search).
Can someone explain why is it behaving like this?
FYI, data is not being inserted/deleted. I am querying multiple indexes (index1, index2 ...) in this example.
Version: 7.16.3