File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed
server/src/main/java/org/opensearch/search/approximate Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -444,7 +444,7 @@ public boolean canApproximate(SearchContext context) {
444
444
if (context .from () + context .size () == 0 ) {
445
445
this .setSize (SearchContext .DEFAULT_TRACK_TOTAL_HITS_UP_TO );
446
446
} else {
447
- this .setSize (Math .max (context .from () + context .size (), context .trackTotalHitsUpTo ()));
447
+ this .setSize (Math .max (context .from () + context .size (), context .trackTotalHitsUpTo () + 1 ));
448
448
}
449
449
if (context .request () != null && context .request ().source () != null ) {
450
450
FieldSortBuilder primarySortField = FieldSortBuilder .getPrimaryFieldSortOrNull (context .request ().source ());
@@ -463,6 +463,7 @@ public boolean canApproximate(SearchContext context) {
463
463
}
464
464
this .setSortOrder (primarySortField .order ());
465
465
}
466
+ return context .request ().source ().terminateAfter () == SearchContext .DEFAULT_TERMINATE_AFTER ;
466
467
}
467
468
return true ;
468
469
}
You can’t perform that action at this time.
0 commit comments