[Bug](ES): Es object mapping error (#18382)

Issue Number: close #18379
This commit is contained in:
Stalary
2023-04-06 14:11:09 +08:00
committed by GitHub
parent db766bb073
commit a474be6d03
3 changed files with 50 additions and 0 deletions

View File

@ -215,6 +215,9 @@ public class EsUtil {
}
private static ObjectNode replaceFieldAlias(ObjectNode mappingProps, ObjectNode fieldValue) {
if (!fieldValue.has("type")) {
return fieldValue;
}
String typeStr = fieldValue.get("type").asText();
if ("alias".equals(typeStr)) {
String path = fieldValue.get("path").asText();

View File

@ -259,4 +259,13 @@ public class EsUtilTest extends EsTestCase {
Assertions.assertEquals("text", parseColumns.get(4).getType().toSql());
}
@Test
public void testComplexType() throws IOException, URISyntaxException {
ObjectNode testFieldAlias = EsUtil.getRootSchema(
EsUtil.getMapping(loadJsonFromFile("data/es/es6_dynamic_complex_type.json")), null, new ArrayList<>());
List<Column> columns = EsUtil.genColumnsFromEs("test_complex_type", "complex_type", testFieldAlias, true,
new ArrayList<>());
Assertions.assertEquals(3, columns.size());
}
}

View File

@ -0,0 +1,38 @@
{
"test_complex_type": {
"mappings": {
"complex_type": {
"dynamic": "true",
"properties": {
"account": {
"properties": {
"test1": {
"type": "double"
},
"test2": {
"type": "double"
},
"test3": {
"type": "double"
},
"test4": {
"type": "double"
}
}
},
"mobile": {
"type": "nested",
"properties": {
"first": {
"type": "text"
},
"last": {
"type": "keyword"
}
}
}
}
}
}
}
}