Skip to content

Commit 5d57c80

Browse files
committed
#AI commit# CC: 修复getProps方法先调用mappings()再序列化 / Fix getProps to call mappings() before serialization
## 问题 / Problem getProps方法中直接对IndexMappingRecord序列化,没有先调用mappings()获取TypeMapping ## 修复 / Fix - 先调用mappingRecord.mappings()获取TypeMapping对象 - 然后对TypeMapping进行JsonpUtils.toJsonString序列化 ## 原因 / Reason IndexMappingRecord包含索引级别的元数据,而mappings()返回的TypeMapping才是实际的字段映射定义。 直接序列化IndexMappingRecord会包含多余的结构,导致后续获取properties时路径不正确。 Fix getProps method to call mappings() on IndexMappingRecord before JsonpUtils.toJsonString serialization. The mappings() method returns TypeMapping which contains the actual field mapping definitions, while IndexMappingRecord includes additional index-level metadata.
1 parent a5997c2 commit 5d57c80

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • exchangis-engines/engines/datax/datax-elasticsearch8xwriter/src/main/java/com/webank/wedatasphere/exchangis/datax/plugin/writer/elasticsearchwriter/v8x

exchangis-engines/engines/datax/datax-elasticsearch8xwriter/src/main/java/com/webank/wedatasphere/exchangis/datax/plugin/writer/elasticsearchwriter/v8x/Elastic8xRestClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ public Map<Object, Object> getProps(String indexName, String typeName) {
365365
GetMappingResponse response = esClient.indices().getMapping(request);
366366
IndexMappingRecord mappingRecord = response.get(indexName);
367367
if (null != mappingRecord){
368-
String mappingJson = JsonpUtils.toJsonString(mappingRecord, esClient._jsonpMapper());
368+
// 先调用mappings()获取TypeMapping,再序列化为JSON
369+
// First call mappings() to get TypeMapping, then serialize to JSON
370+
String mappingJson = JsonpUtils.toJsonString(mappingRecord.mappings(), esClient._jsonpMapper());
369371
Map<String, Object> mappingMap = Json.fromJson(mappingJson, Map.class);
370372
if (null != mappingMap){
371373
Object props = mappingMap.get(FIELD_PROPS);

0 commit comments

Comments
 (0)