Hisoka-X commented on code in PR #8895:
URL: https://github.com/apache/seatunnel/pull/8895#discussion_r1982847262


##########
docs/zh/connector-v2/source/Elasticsearch.md:
##########
@@ -244,4 +246,21 @@ source {
         tls_keystore_password = "${your password}"
     }
 }
+```
+
+案例六 : sql 方式查询
+notes: sql does not support map and array types

Review Comment:
   Please use chinese here.



##########
seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/config/ElasticsearchSourceOptions.java:
##########
@@ -61,6 +61,18 @@ public class ElasticsearchSourceOptions extends 
ElasticsearchBaseOptions {
                     .withDescription(
                             "Amount of time Elasticsearch will keep the search 
context alive for scroll requests");
 
+    public static final Option<String> SEARCH_TYPE =
+            Options.key("search_type")
+                    .stringType()
+                    .defaultValue("dsl")

Review Comment:
   use enum?



##########
seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/source/ElasticsearchSourceReader.java:
##########
@@ -74,22 +79,11 @@ public void pollNext(Collector<SeaTunnelRow> output) throws 
Exception {
             ElasticsearchSourceSplit split = splits.poll();
             if (split != null) {
                 SeaTunnelRowType seaTunnelRowType = 
split.getSeaTunnelRowType();
-                SeaTunnelRowDeserializer deserializer =
-                        new DefaultSeaTunnelRowDeserializer(seaTunnelRowType);
                 ElasticsearchConfig sourceIndexInfo = 
split.getElasticsearchConfig();
-                ScrollResult scrollResult =
-                        esRestClient.searchByScroll(
-                                sourceIndexInfo.getIndex(),
-                                sourceIndexInfo.getSource(),
-                                sourceIndexInfo.getQuery(),
-                                sourceIndexInfo.getScrollTime(),
-                                sourceIndexInfo.getScrollSize());
-                outputFromScrollResult(scrollResult, sourceIndexInfo, output, 
deserializer);
-                while (scrollResult.getDocs() != null && 
scrollResult.getDocs().size() > 0) {
-                    scrollResult =
-                            esRestClient.searchWithScrollId(
-                                    scrollResult.getScrollId(), 
sourceIndexInfo.getScrollTime());
-                    outputFromScrollResult(scrollResult, sourceIndexInfo, 
output, deserializer);
+                if 
(SQL_TYPE.equalsIgnoreCase(sourceIndexInfo.getSearchType())) {
+                    cursorSearchResult(seaTunnelRowType, sourceIndexInfo, 
output);
+                } else {
+                    scrollSearchResult(seaTunnelRowType, sourceIndexInfo, 
output);

Review Comment:
   what's different between `cursorSearchResult` and `scrollSearchResult`? Can 
we merge it?



##########
seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/dto/source/CursorResult.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seatunnel.connectors.seatunnel.elasticsearch.dto.source;

Review Comment:
   ```suggestion
   package org.apache.seatunnel.connectors.seatunnel.elasticsearch.client;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to