Handle total hits equal to track_total_hits (#37907)

This change ensures that a total hits equal to the value set for
track_total_hits is not considered as a lower bound.
This commit is contained in:
Jim Ferenczi 2019-03-05 12:03:39 +01:00 committed by jimczi
parent e94d32d069
commit 160dc29f0e
2 changed files with 15 additions and 3 deletions

View File

@ -56,7 +56,7 @@ setup:
---
"hits.total as an object":
- skip:
version: " - 6.99.99"
version: " - 7.0.99"
reason: hits.total is rendered as an object in 7.0.0
- do:
@ -106,7 +106,7 @@ setup:
- do:
search:
size: 3
size: 0
track_total_hits: 4
body:
query:
@ -116,6 +116,18 @@ setup:
- match: {hits.total.value: 4}
- match: {hits.total.relation: gte}
- do:
search:
size: 0
track_total_hits: 5
body:
query:
match:
foo: bar
- match: {hits.total.value: 5}
- match: {hits.total.relation: eq}
- do:
catch: /\[rest_total_hits_as_int\] cannot be used if the tracking of total hits is not accurate, got 100/
search:

View File

@ -754,7 +754,7 @@ public final class SearchPhaseController {
assert totalHitsRelation == Relation.EQUAL_TO;
return new TotalHits(totalHits, totalHitsRelation);
} else {
if (totalHits < trackTotalHitsUpTo) {
if (totalHits <= trackTotalHitsUpTo) {
return new TotalHits(totalHits, totalHitsRelation);
} else {
/*