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) {
444444 if (context .from () + context .size () == 0 ) {
445445 this .setSize (SearchContext .DEFAULT_TRACK_TOTAL_HITS_UP_TO );
446446 } else {
447- this .setSize (Math .max (context .from () + context .size (), context .trackTotalHitsUpTo ()));
447+ this .setSize (Math .max (context .from () + context .size (), context .trackTotalHitsUpTo () + 1 ));
448448 }
449449 if (context .request () != null && context .request ().source () != null ) {
450450 FieldSortBuilder primarySortField = FieldSortBuilder .getPrimaryFieldSortOrNull (context .request ().source ());
@@ -463,6 +463,7 @@ public boolean canApproximate(SearchContext context) {
463463 }
464464 this .setSortOrder (primarySortField .order ());
465465 }
466+ return context .request ().source ().terminateAfter () == SearchContext .DEFAULT_TERMINATE_AFTER ;
466467 }
467468 return true ;
468469 }
You can’t perform that action at this time.
0 commit comments