Skip to content

Commit

Permalink
[Feature][Connector-V2]fix JsonNode convert to Map(apache#2553)
Browse files Browse the repository at this point in the history
  • Loading branch information
iture123 committed Sep 6, 2022
1 parent 36d6ba2 commit a7207fb
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.apache.seatunnel.shade.com.typesafe.config.Config;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand Down Expand Up @@ -61,6 +62,8 @@ public class EsRestClient {

private final RestClient restClient;

private final ObjectMapper mapper = new ObjectMapper();

private EsRestClient(RestClient restClient) {
this.restClient = restClient;
}
Expand Down Expand Up @@ -227,7 +230,7 @@ private ScrollResult getDocsFromScrollResponse(ObjectNode responseJson) {
JsonNode hitNode = iter.next();
doc.put("_index", hitNode.get("_index").textValue());
doc.put("_id", hitNode.get("_id").textValue());
Map<String, Object> source = JsonUtils.parseObject(hitNode.get("_source").toPrettyString(), Map.class);
Map<String, Object> source = mapper.convertValue(hitNode.get("_source"), new TypeReference<Map<String, Object>>(){});
doc.putAll(source);
docs.add(doc);
}
Expand Down

0 comments on commit a7207fb

Please sign in to comment.