From 3af87c4828e99de6ce6acff6290adaa574194b61 Mon Sep 17 00:00:00 2001 From: Rupal Mahajan Date: Thu, 13 Jun 2024 23:26:20 -0700 Subject: [PATCH] nit Signed-off-by: Rupal Mahajan --- .../legacy/executor/join/ElasticJoinExecutor.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java index cb0fd01c07..f89e26a75f 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java @@ -268,22 +268,21 @@ public SearchResponse getResponseWithHits( SearchResponse previousResponse) { // Set Size SearchRequestBuilder request = tableRequest.getRequestBuilder().setSize(size); - - // Set sort field for search_after - boolean ordered = tableRequest.getOriginalSelect().isOrderdSelect(); - if (!ordered) { - request.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC); - } - SearchResponse responseWithHits; - // Set PIT or scroll if (LocalClusterState.state().getSettingValue(SQL_PAGINATION_API_SEARCH_AFTER)) { + // Set sort field for search_after + boolean ordered = tableRequest.getOriginalSelect().isOrderdSelect(); + if (!ordered) { + request.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC); + } + // Set PIT request.setPointInTime(new PointInTimeBuilder(tableRequest.getPitId())); if (previousResponse != null) { request.searchAfter(previousResponse.getHits().getSortFields()); } responseWithHits = request.get(); } else { + // Set scroll TimeValue keepAlive = LocalClusterState.state().getSettingValue(SQL_CURSOR_KEEP_ALIVE); if (previousResponse != null) { responseWithHits =