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 @@ -448,7 +448,7 @@ public boolean canApproximate(SearchContext context) {
448
448
if (context .from () + context .size () == 0 ) {
449
449
this .setSize (SearchContext .DEFAULT_TRACK_TOTAL_HITS_UP_TO );
450
450
} else {
451
- this .setSize (Math .max (context .from () + context .size (), context .trackTotalHitsUpTo ()));
451
+ this .setSize (Math .max (context .from () + context .size (), context .trackTotalHitsUpTo () + 1 ));
452
452
}
453
453
if (context .request () != null && context .request ().source () != null ) {
454
454
FieldSortBuilder primarySortField = FieldSortBuilder .getPrimaryFieldSortOrNull (context .request ().source ());
@@ -467,6 +467,7 @@ public boolean canApproximate(SearchContext context) {
467
467
}
468
468
this .setSortOrder (primarySortField .order ());
469
469
}
470
+ return context .request ().source ().terminateAfter () == SearchContext .DEFAULT_TERMINATE_AFTER ;
470
471
}
471
472
return true ;
472
473
}
You can’t perform that action at this time.
0 commit comments