@ -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();
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user