diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSQLQueryAction.java b/legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSQLQueryAction.java index 9594d5a3b5..bd9387a68e 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSQLQueryAction.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSQLQueryAction.java @@ -119,7 +119,7 @@ private ResponseListener fallBackListener( return new ResponseListener() { @Override public void onResponse(T response) { - LOG.error("[{}] Request is handled by new SQL query engine", + LOG.info("[{}] Request is handled by new SQL query engine", QueryContext.getRequestId()); next.onResponse(response); } @@ -172,7 +172,7 @@ private ResponseListener createQueryResponseListener( @Override public void onResponse(QueryResponse response) { sendResponse(channel, OK, - formatter.format(new QueryResult(response.getSchema(), response.getResults()))); + formatter.format(new QueryResult(response.getSchema(), response.getResults(), response.getCursor()))); } @Override diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/request/OpenSearchScrollRequest.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/request/OpenSearchScrollRequest.java index 456739cef0..7755388842 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/request/OpenSearchScrollRequest.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/request/OpenSearchScrollRequest.java @@ -33,7 +33,7 @@ public class OpenSearchScrollRequest implements OpenSearchRequest { /** Default scroll context timeout in minutes. */ - public static final TimeValue DEFAULT_SCROLL_TIMEOUT = TimeValue.timeValueMinutes(1L); + public static final TimeValue DEFAULT_SCROLL_TIMEOUT = TimeValue.timeValueMinutes(100L); /** * {@link OpenSearchRequest.IndexName}. @@ -86,6 +86,7 @@ public OpenSearchResponse search(Function searchA } else { openSearchResponse = searchAction.apply(searchRequest()); } + setScrollId(openSearchResponse.getScrollId()); return new OpenSearchResponse(openSearchResponse, exprValueFactory); diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java index aadd73efdd..c2042d7c0e 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java @@ -71,6 +71,7 @@ public OpenSearchResponse(SearchHits hits, OpenSearchExprValueFactory exprValueF */ public boolean isEmpty() { return (hits.getHits() == null) || (hits.getHits().length == 0) && aggregations == null; + // TODO TBD ^ ^ } public boolean isAggregationResponse() { diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java index e07404bd18..3c431a15ff 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java @@ -39,7 +39,7 @@ public OpenSearchResponse search(Function searchA Function scrollAction) { SearchResponse openSearchResponse; - openSearchResponse = scrollAction.apply(new SearchScrollRequest(initialScrollId)); + openSearchResponse = scrollAction.apply(new SearchScrollRequest(initialScrollId)); responseScrollId = openSearchResponse.getScrollId(); return new OpenSearchResponse(openSearchResponse, exprValueFactory); diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/InitialPageRequestBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/InitialPageRequestBuilder.java index 6a453a9526..e36e0df529 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/InitialPageRequestBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/InitialPageRequestBuilder.java @@ -45,7 +45,7 @@ public InitialPageRequestBuilder(OpenSearchRequest.IndexName indexName, Settings this.indexName = indexName; this.sourceBuilder = new SearchSourceBuilder(); this.exprValueFactory = exprValueFactory; - this.querySize = settings.getSettingValue(Settings.Key.QUERY_SIZE_LIMIT); + this.querySize = settings.getSettingValue(Settings.Key.QUERY_SIZE_LIMIT);//TODO fetch_size sourceBuilder.from(0); sourceBuilder.size(querySize); sourceBuilder.timeout(DEFAULT_QUERY_TIMEOUT); diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java index 111a7bec94..ea09502b0e 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java @@ -53,7 +53,7 @@ public void open() { OpenSearchResponse response = client.search(request); if (!response.isEmpty()) { iterator = response.iterator(); - } + } // TODO else - last page is empty - } @Override