@@ -23,6 +23,10 @@ public void checkClusterFeature() {
2323 }
2424
2525 @ SuppressWarnings ("unchecked" )
26+ private Map <String , Object > getFieldMapping (Map <String , Object > mapping , String fieldName ) {
27+ return (Map <String , Object >) ((Map <String , Object >) mapping .get ("properties" )).get (fieldName );
28+ }
29+
2630 public void testStandardIndex () throws IOException {
2731 final String dataStreamName = "test-foo" ;
2832
@@ -54,9 +58,7 @@ public void testStandardIndex() throws IOException {
5458 {
5559 assertEquals ("true" , getSetting (client (), backingIndex0 , "index.mapping.pattern_text.disable_templating" ));
5660 Map <String , Object > mapping = getMapping (client (), backingIndex0 );
57- Map <String , Object > patternFieldMapping = (Map <String , Object >) ((Map <String , Object >) mapping .get ("properties" )).get (
58- "pattern_field"
59- );
61+ Map <String , Object > patternFieldMapping = getFieldMapping (mapping , "pattern_field" );
6062 assertThat (patternFieldMapping , hasEntry ("disable_templating" , true ));
6163 }
6264
@@ -66,14 +68,11 @@ public void testStandardIndex() throws IOException {
6668 {
6769 assertEquals ("true" , getSetting (client (), backingIndex1 , "index.mapping.pattern_text.disable_templating" ));
6870 Map <String , Object > mapping = getMapping (client (), backingIndex1 );
69- Map <String , Object > patternFieldMapping = (Map <String , Object >) ((Map <String , Object >) mapping .get ("properties" )).get (
70- "pattern_field"
71- );
71+ Map <String , Object > patternFieldMapping = getFieldMapping (mapping , "pattern_field" );
7272 assertThat (patternFieldMapping , hasEntry ("disable_templating" , true ));
7373 }
7474 }
7575
76- @ SuppressWarnings ("unchecked" )
7776 public void testLogsdbIndex () throws IOException {
7877 final String dataStreamName = "test-bar" ;
7978
@@ -84,7 +83,8 @@ public void testLogsdbIndex() throws IOException {
8483 "data_stream": {},
8584 "template": {
8685 "settings": {
87- "index.mode": "logsdb"
86+ "index.mode": "logsdb",
87+ "index.logsdb.default_sort_on_message_template": true
8888 },
8989 "mappings": {
9090 "properties": {
@@ -119,9 +119,7 @@ public void testLogsdbIndex() throws IOException {
119119 getSetting (client (), backingIndex0 , "index.sort.field" )
120120 );
121121 Map <String , Object > mapping = getMapping (client (), backingIndex0 );
122- Map <String , Object > patternFieldMapping = (Map <String , Object >) ((Map <String , Object >) mapping .get ("properties" )).get (
123- "message"
124- );
122+ Map <String , Object > patternFieldMapping = getFieldMapping (mapping , "message" );
125123 assertThat (patternFieldMapping , hasEntry ("disable_templating" , true ));
126124 }
127125
@@ -135,9 +133,7 @@ public void testLogsdbIndex() throws IOException {
135133 getSetting (client (), backingIndex1 , "index.sort.field" )
136134 );
137135 Map <String , Object > mapping = getMapping (client (), backingIndex1 );
138- Map <String , Object > patternFieldMapping = (Map <String , Object >) ((Map <String , Object >) mapping .get ("properties" )).get (
139- "message"
140- );
136+ Map <String , Object > patternFieldMapping = getFieldMapping (mapping , "message" );
141137 assertThat (patternFieldMapping , hasEntry ("disable_templating" , true ));
142138 }
143139 }
0 commit comments