File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
server/src/main/java/org/opensearch/search/approximate Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ protected boolean canApproximate(SearchContext context) {
36
36
if (context .aggregations () != null ) {
37
37
return false ;
38
38
}
39
+ // When "track_total_hits": true,
40
+ if (context .trackTotalHitsUpTo () == SearchContext .TRACK_TOTAL_HITS_ACCURATE ) {
41
+ return false ;
42
+ }
39
43
40
44
if (context .request () != null && context .request ().source () != null && context .innerHits ().getInnerHits ().isEmpty ()) {
41
45
FieldSortBuilder primarySortField = FieldSortBuilder .getPrimaryFieldSortOrNull (context .request ().source ());
Original file line number Diff line number Diff line change @@ -440,6 +440,11 @@ public boolean canApproximate(SearchContext context) {
440
440
if (context .aggregations () != null ) {
441
441
return false ;
442
442
}
443
+ // When "track_total_hits": true,
444
+ if (context .trackTotalHitsUpTo () == SearchContext .TRACK_TOTAL_HITS_ACCURATE ) {
445
+ return false ;
446
+ }
447
+
443
448
// size 0 could be set for caching
444
449
if (context .from () + context .size () == 0 ) {
445
450
this .setSize (SearchContext .DEFAULT_TRACK_TOTAL_HITS_UP_TO );
You can’t perform that action at this time.
0 commit comments