This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new a8e0f977e1 [pick] es catalog Unexpected exception (#19064) a8e0f977e1 is described below commit a8e0f977e197d414ef0a57b14915ef99d37bac6f Author: gnehil <adamlee...@gmail.com> AuthorDate: Sun Apr 30 17:34:05 2023 +0800 [pick] es catalog Unexpected exception (#19064) cherry-pick: #18438 --- .../doris/external/elasticsearch/EsUtil.java | 2 ++ .../doris/external/elasticsearch/EsUtilTest.java | 10 ++++++++++ .../test/resources/data/es/dynamic_mappings.json | 23 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/external/elasticsearch/EsUtil.java b/fe/fe-core/src/main/java/org/apache/doris/external/elasticsearch/EsUtil.java index f5ba8ffc38..ef26eaf0e4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/external/elasticsearch/EsUtil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/external/elasticsearch/EsUtil.java @@ -153,6 +153,8 @@ public class EsUtil { } // remove `dynamic_templates` field mappings.remove("dynamic_templates"); + // remove `dynamic` field + mappings.remove("dynamic"); // check explicit mapping if (mappings.isEmpty()) { throw new DorisEsException("Do not support index without explicit mapping."); diff --git a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java index 6706ccd777..31c4238980 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java @@ -250,4 +250,14 @@ public class EsUtilTest extends EsTestCase { } } + @Test + public void testDynamicMapping() throws IOException, URISyntaxException { + + ObjectNode testAliases = EsUtil.getMappingProps("test", loadJsonFromFile("data/es/dynamic_mappings.json"), + null); + Assertions.assertEquals("{\"time\":{\"type\":\"long\"},\"type\":{\"type\":\"keyword\"},\"userId\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}}}", + testAliases.toString()); + + } + } diff --git a/fe/fe-core/src/test/resources/data/es/dynamic_mappings.json b/fe/fe-core/src/test/resources/data/es/dynamic_mappings.json new file mode 100644 index 0000000000..1388514297 --- /dev/null +++ b/fe/fe-core/src/test/resources/data/es/dynamic_mappings.json @@ -0,0 +1,23 @@ +{ + "test_index": { + "mappings": { + "dynamic": "false", + "properties": { + "time": { + "type": "long" + }, + "type": { + "type": "keyword" + }, + "userId": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + } + } + } + } +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org