Skip to content

Commit

Permalink
Addressig review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Chaitanya Gohel <[email protected]>
  • Loading branch information
gashutos committed Nov 20, 2023
1 parent 5236b2f commit d9270f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,7 @@ private boolean canMatch(LeafReaderContext ctx) throws IOException {
}

private boolean canMatchSearchAfter(LeafReaderContext ctx) throws IOException {
if (searchContext.searchAfter() != null
&& searchContext.sort() != null
&& searchContext.request() != null
&& searchContext.request().source() != null) {
if (searchContext.searchAfter() != null && searchContext.request() != null && searchContext.request().source() != null) {
// Only applied on primary sort field and primary search_after.
FieldSortBuilder primarySortField = FieldSortBuilder.getPrimaryFieldSortOrNull(searchContext.request().source());
if (primarySortField != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ public static FieldSortBuilder getPrimaryFieldSortOrNull(SearchSourceBuilder sou
* and configurations return <code>null</code>.
*/
public static MinAndMax<?> getMinMaxOrNull(QueryShardContext context, FieldSortBuilder sortBuilder) throws IOException {
return getMinMaxOrNullInternal(context.getIndexReader(), context, sortBuilder, null);
final SortAndFormats sort = SortBuilder.buildSort(Collections.singletonList(sortBuilder), context).get();
return getMinMaxOrNullInternal(context.getIndexReader(), context, sortBuilder, sort);
}

/**
Expand All @@ -634,9 +635,6 @@ private static MinAndMax<?> getMinMaxOrNullInternal(
FieldSortBuilder sortBuilder,
SortAndFormats sort
) throws IOException {
if (sort == null) {
sort = SortBuilder.buildSort(Collections.singletonList(sortBuilder), context).get();
}
SortField sortField = sort.sort.getSort()[0];
if (sortField.getField() == null) {
return null;
Expand Down

0 comments on commit d9270f6

Please sign in to comment.