Skip to content

Commit 0b94c99

Browse files
Update allowed mapping changes (#19)
1 parent 8b18128 commit 0b94c99

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

elastic-mapping-updater/src/main/java/com/github/cafdataprocessing/elastic/tools/ElasticMappingUpdater.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ public final class ElasticMappingUpdater
6565
"fields",
6666
"ignore_above",
6767
"ignore_malformed",
68-
"index_options",
6968
"meta",
70-
"null_value",
71-
"position_increment_gap",
7269
"properties",
7370
"search_analyzer",
7471
"search_quote_analyzer")));

elastic-mapping-updater/src/test/java/com/github/cafdataprocessing/elastic/tools/test/ElasticMappingUpdaterIT.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ public void testUpdateIndexesOfUnSupportedChangesInTemplate() throws IOException
508508
final Map<String, Object> idPropMapping = (Map<String, Object>) props.get("ID");
509509
LOGGER.info("idPropMapping {} ", idPropMapping);
510510
final Object idPropValue = idPropMapping.get("ignore_malformed");
511-
// Verify property mapping parameter was not removed (although mapping update was to remove the ignore_malformed parameter)
512-
assertNotNull("testUpdateIndexesOfUnSupportedChangesInTemplate", idPropValue);
511+
// Verify property mapping parameter was removed
512+
assertNull("testUpdateIndexesOfUnSupportedChangesInTemplate", idPropValue);
513513

514514
// Verify index mapping of unsupported field changes has not changed
515515
@SuppressWarnings("unchecked")
@@ -642,9 +642,9 @@ public void testUpdateIndexesWithNestedFieldChanges() throws IOException, GetInd
642642
@SuppressWarnings("unchecked")
643643
final Map<String, Object> gidMapping = (Map<String, Object>) entitiesProps.get("GRAMMAR_ID");
644644
assertNotNull("testUpdateIndexesOfUnSupportedChangesInTemplate", gidMapping);
645-
// Verify change to nested property is applied, param added (allowed change)
645+
// Verify change to nested property is applied, param not added (change not allowed)
646646
final Object gidProp1 = gidMapping.get("null_value");
647-
assertNotNull("testUpdateIndexesOfUnSupportedChangesInTemplate", gidProp1);
647+
assertNull("testUpdateIndexesOfUnSupportedChangesInTemplate", gidProp1);
648648

649649
// Verify index mapping of unsupported field changes to nested property has not changed
650650
@SuppressWarnings("unchecked")
@@ -778,8 +778,8 @@ public void testAttemptRemoveUnchangeableProperty() throws Exception
778778
final Map<String, Object> processingProps = (Map<String, Object>) processingPropMapping.get("properties");
779779
@SuppressWarnings("unchecked")
780780
final Map<String, Object> propIdMapping = (Map<String, Object>) processingProps.get("ID");
781-
// Verify param removed (allowed change)
782-
assertFalse(propIdMapping.containsKey("null_value"));
781+
// Verify param not removed (change not allowed)
782+
assertTrue(propIdMapping.containsKey("null_value"));
783783
@SuppressWarnings("unchecked")
784784
final Map<String, Object> pTimeMapping = (Map<String, Object>) processingProps.get("P_TIME");
785785
assertNotNull("testUpdateIndexesOfUnSupportedChangesInTemplate", pTimeMapping);
@@ -789,9 +789,9 @@ public void testAttemptRemoveUnchangeableProperty() throws Exception
789789

790790
@SuppressWarnings("unchecked")
791791
final Map<String, Object> refMapping = (Map<String, Object>) processingProps.get("REF");
792-
// Verify change to nested property is not applied, param not removed
792+
// Verify change to nested property is applied, param removed
793793
final Object propIgnoreMalformed = refMapping.get("ignore_malformed");
794-
assertNotNull("testUpdateIndexesOfUnSupportedChangesInTemplate", propIgnoreMalformed);
794+
assertNull("testUpdateIndexesOfUnSupportedChangesInTemplate", propIgnoreMalformed);
795795

796796
@SuppressWarnings("unchecked")
797797
final Map<String, Object> codeMapping = (Map<String, Object>) processingProps.get("CODE");
@@ -862,7 +862,7 @@ public void testRemoveParams() throws Exception
862862

863863
@SuppressWarnings("unchecked")
864864
final Map<String, Object> prop1Mapping = (Map<String, Object>) props.get("number_two");
865-
assertTrue(prop1Mapping.containsKey("coerce"));
865+
assertFalse(prop1Mapping.containsKey("coerce")); // has been removed, as expected
866866

867867
@SuppressWarnings("unchecked")
868868
final Map<String, Object> prop16Mapping = (Map<String, Object>) props.get("first_name");
@@ -886,19 +886,19 @@ public void testRemoveParams() throws Exception
886886

887887
@SuppressWarnings("unchecked")
888888
final Map<String, Object> prop4Mapping = (Map<String, Object>) props.get("number_one");
889-
assertTrue(prop4Mapping.containsKey("ignore_malformed"));
889+
assertFalse(prop4Mapping.containsKey("ignore_malformed")); // has been removed, as expected
890890

891891
@SuppressWarnings("unchecked")
892892
final Map<String, Object> prop20Mapping = (Map<String, Object>) props.get("dummy_message2");
893-
assertFalse(prop20Mapping.containsKey("index_options")); // has been removed
893+
assertTrue(prop20Mapping.containsKey("index_options")); // has not been removed, as expected
894894

895895
@SuppressWarnings("unchecked")
896896
final Map<String, Object> prop24Mapping = (Map<String, Object>) props.get("latency");
897897
assertTrue(prop24Mapping.containsKey("meta"));
898898

899899
@SuppressWarnings("unchecked")
900900
final Map<String, Object> prop5Mapping = (Map<String, Object>) props.get("status_code");
901-
assertFalse(prop5Mapping.containsKey("null_value")); // has been removed
901+
assertTrue(prop5Mapping.containsKey("null_value")); // not removed, as expected
902902

903903
@SuppressWarnings("unchecked")
904904
final Map<String, Object> prop27Mapping = (Map<String, Object>) props.get("names2");
@@ -1056,19 +1056,19 @@ public void testAddParams() throws Exception
10561056

10571057
@SuppressWarnings("unchecked")
10581058
final Map<String, Object> prop20Mapping = (Map<String, Object>) props.get("dummy_message2");
1059-
assertTrue(prop20Mapping.containsKey("index_options"));
1059+
assertFalse(prop20Mapping.containsKey("index_options")); // has not been added, as expected
10601060

10611061
@SuppressWarnings("unchecked")
10621062
final Map<String, Object> prop24Mapping = (Map<String, Object>) props.get("latency");
10631063
assertFalse(prop24Mapping.containsKey("meta")); // has not been added
10641064

10651065
@SuppressWarnings("unchecked")
10661066
final Map<String, Object> prop5Mapping = (Map<String, Object>) props.get("status_code");
1067-
assertTrue(prop5Mapping.containsKey("null_value"));
1067+
assertFalse(prop5Mapping.containsKey("null_value")); // not added, as expected
10681068

10691069
@SuppressWarnings("unchecked")
10701070
final Map<String, Object> prop27Mapping = (Map<String, Object>) props.get("names2");
1071-
assertFalse(prop27Mapping.containsKey("position_increment_gap")); // has not been added
1071+
assertFalse(prop27Mapping.containsKey("position_increment_gap")); // not added, as expected
10721072

10731073
@SuppressWarnings("unchecked")
10741074
final Map<String, Object> prop28Mapping = (Map<String, Object>) props.get("manager");
@@ -1201,25 +1201,25 @@ public void testAddRemoveParams() throws Exception
12011201

12021202
@SuppressWarnings("unchecked")
12031203
final Map<String, Object> prop10Mapping = (Map<String, Object>) propOtherPropsMappings.get("status_code");
1204-
assertTrue(prop10Mapping.containsKey("null_value")); // added, as expected
1204+
assertFalse(prop10Mapping.containsKey("null_value")); // not added, as expected
12051205

12061206
@SuppressWarnings("unchecked")
12071207
final Map<String, Object> prop11Mapping = (Map<String, Object>) propOtherPropsMappings.get("BODY_TEXT");
12081208
assertTrue(prop11Mapping.containsKey("index_prefixes")); // not removed, as expected
12091209

12101210
@SuppressWarnings("unchecked")
12111211
final Map<String, Object> prop12Mapping = (Map<String, Object>) propOtherPropsMappings.get("REF");
1212-
assertTrue(prop12Mapping.containsKey("ignore_malformed")); // not removed
1212+
assertFalse(prop12Mapping.containsKey("ignore_malformed")); // removed, as expected
12131213

12141214
@SuppressWarnings("unchecked")
12151215
final Map<String, Object> prop13Mapping = (Map<String, Object>) propOtherPropsMappings.get("some_date");
12161216
assertFalse(prop13Mapping.containsKey("format")); // not added, as expected
12171217

12181218
@SuppressWarnings("unchecked")
12191219
final Map<String, Object> propId = (Map<String, Object>) propProcessingMappings.get("ID");
1220-
assertTrue(propId.containsKey("eager_global_ordinals")); // added, as expected
1220+
assertFalse(propId.containsKey("eager_global_ordinals")); // not added, unexpected (can be removed but not added?)
12211221
assertTrue(propId.containsKey("ignore_above"));
1222-
assertFalse(propId.containsKey("null_value")); // removed, as expected
1222+
assertTrue(propId.containsKey("null_value")); // not removed, as expected
12231223

12241224
@SuppressWarnings("unchecked")
12251225
final Map<String, Object> propLang = (Map<String, Object>) props.get("LANGUAGE_CODES");

0 commit comments

Comments
 (0)