[fix](es catalog) remove _default_ field when parsing mapping. (#24781)
This commit is contained in:
@ -154,6 +154,10 @@ public class EsUtil {
|
||||
mappings.remove("dynamic_templates");
|
||||
// remove `dynamic` field
|
||||
mappings.remove("dynamic");
|
||||
// remove `_default` field, we do not parse `_default_` mapping, only explicit mapping.
|
||||
// `_default` _mapping type is deprecated in 7.0 and removed in 8.0
|
||||
// https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html
|
||||
mappings.remove("_default_");
|
||||
// check explicit mapping
|
||||
if (mappings.isEmpty()) {
|
||||
throw new DorisEsException("Do not support index without explicit mapping.");
|
||||
|
||||
@ -278,5 +278,12 @@ public class EsUtilTest extends EsTestCase {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultMapping() throws IOException, URISyntaxException {
|
||||
ObjectNode testAliases = EsUtil.getMappingProps("test", loadJsonFromFile("data/es/default_mappings.json"),
|
||||
null);
|
||||
Assertions.assertEquals("{\"@timestamp\":{\"type\":\"date\"},\"@version\":{\"type\":\"keyword\"},\"act\":{\"type\":\"text\",\"norms\":false,\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\"app\":{\"type\":\"text\",\"norms\":false,\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\"tags\":{\"type\":\"text\",\"norms\":false,\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\"type\":{\"type\":\"text\",\"norms\":false,\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\"uid\":{\"type\":\"text\",\"norms\":false,\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}}}",
|
||||
testAliases.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
149
fe/fe-core/src/test/resources/data/es/default_mappings.json
Normal file
149
fe/fe-core/src/test/resources/data/es/default_mappings.json
Normal file
@ -0,0 +1,149 @@
|
||||
{
|
||||
"test" : {
|
||||
"mappings" : {
|
||||
"_default_" : {
|
||||
"dynamic_templates" : [
|
||||
{
|
||||
"message_field" : {
|
||||
"path_match" : "message",
|
||||
"match_mapping_type" : "string",
|
||||
"mapping" : {
|
||||
"norms" : false,
|
||||
"type" : "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"string_fields" : {
|
||||
"match" : "*",
|
||||
"match_mapping_type" : "string",
|
||||
"mapping" : {
|
||||
"fields" : {
|
||||
"keyword" : {
|
||||
"ignore_above" : 256,
|
||||
"type" : "keyword"
|
||||
}
|
||||
},
|
||||
"norms" : false,
|
||||
"type" : "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"properties" : {
|
||||
"@timestamp" : {
|
||||
"type" : "date"
|
||||
},
|
||||
"@version" : {
|
||||
"type" : "keyword"
|
||||
},
|
||||
"geoip" : {
|
||||
"dynamic" : "true",
|
||||
"properties" : {
|
||||
"ip" : {
|
||||
"type" : "ip"
|
||||
},
|
||||
"latitude" : {
|
||||
"type" : "half_float"
|
||||
},
|
||||
"location" : {
|
||||
"type" : "geo_point"
|
||||
},
|
||||
"longitude" : {
|
||||
"type" : "half_float"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"doc" : {
|
||||
"dynamic_templates" : [
|
||||
{
|
||||
"message_field" : {
|
||||
"path_match" : "message",
|
||||
"match_mapping_type" : "string",
|
||||
"mapping" : {
|
||||
"norms" : false,
|
||||
"type" : "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"string_fields" : {
|
||||
"match" : "*",
|
||||
"match_mapping_type" : "string",
|
||||
"mapping" : {
|
||||
"fields" : {
|
||||
"keyword" : {
|
||||
"ignore_above" : 256,
|
||||
"type" : "keyword"
|
||||
}
|
||||
},
|
||||
"norms" : false,
|
||||
"type" : "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"properties" : {
|
||||
"@timestamp" : {
|
||||
"type" : "date"
|
||||
},
|
||||
"@version" : {
|
||||
"type" : "keyword"
|
||||
},
|
||||
"act" : {
|
||||
"type" : "text",
|
||||
"norms" : false,
|
||||
"fields" : {
|
||||
"keyword" : {
|
||||
"type" : "keyword",
|
||||
"ignore_above" : 256
|
||||
}
|
||||
}
|
||||
},
|
||||
"app" : {
|
||||
"type" : "text",
|
||||
"norms" : false,
|
||||
"fields" : {
|
||||
"keyword" : {
|
||||
"type" : "keyword",
|
||||
"ignore_above" : 256
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags" : {
|
||||
"type" : "text",
|
||||
"norms" : false,
|
||||
"fields" : {
|
||||
"keyword" : {
|
||||
"type" : "keyword",
|
||||
"ignore_above" : 256
|
||||
}
|
||||
}
|
||||
},
|
||||
"type" : {
|
||||
"type" : "text",
|
||||
"norms" : false,
|
||||
"fields" : {
|
||||
"keyword" : {
|
||||
"type" : "keyword",
|
||||
"ignore_above" : 256
|
||||
}
|
||||
}
|
||||
},
|
||||
"uid" : {
|
||||
"type" : "text",
|
||||
"norms" : false,
|
||||
"fields" : {
|
||||
"keyword" : {
|
||||
"type" : "keyword",
|
||||
"ignore_above" : 256
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user