@@ -151,6 +151,8 @@ public class DownsampleActionSingleNodeTests extends ESSingleNodeTestCase {
151151 public static final String FIELD_LABEL_KEYWORD_ARRAY = "label_keyword_array" ;
152152 public static final String FIELD_LABEL_DOUBLE_ARRAY = "label_double_array" ;
153153 public static final String FIELD_LABEL_AGG_METRIC = "label_agg_metric" ;
154+ public static final String FIELD_LABEL_FLATTENED = "label_flattened" ;
155+
154156
155157 private static final int MAX_DIM_VALUES = 5 ;
156158 private static final long MAX_NUM_BUCKETS = 10 ;
@@ -257,6 +259,7 @@ public void setup() throws IOException {
257259 .array ("metrics" , new String [] { "min" , "max" , "sum" , "value_count" })
258260 .field ("default_metric" , "value_count" )
259261 .endObject ();
262+ mapping .startObject (FIELD_LABEL_FLATTENED ).field ("type" , "flattened" ).endObject ();
260263
261264 mapping .endObject ().endObject ().endObject ();
262265 assertAcked (indicesAdmin ().prepareCreate (sourceIndex ).setSettings (settings .build ()).setMapping (mapping ).get ());
@@ -321,6 +324,31 @@ public void testDownsampleIndex() throws Exception {
321324 assertDownsampleIndex (sourceIndex , downsampleIndex , config );
322325 }
323326
327+ public void testDownsampleIndexWithFlattenedLabel () throws Exception {
328+ DownsampleConfig config = new DownsampleConfig (randomInterval ());
329+ SourceSupplier sourceSupplier = () -> {
330+ String ts = randomDateForInterval (config .getInterval ());
331+ return XContentFactory .jsonBuilder ()
332+ .startObject ()
333+ .field (FIELD_TIMESTAMP , ts )
334+ .field (FIELD_DIMENSION_1 , "dim1" ) // not important for this test
335+ .startObject (FIELD_LABEL_FLATTENED )
336+ .field (FIELD_LABEL_KEYWORD , randomAlphaOfLength (5 ))
337+ .endObject ()
338+ .startObject (FIELD_AGG_METRIC )
339+ .field ("min" , randomDoubleBetween (-2000 , -1001 , true ))
340+ .field ("max" , randomDoubleBetween (-1000 , 1000 , true ))
341+ .field ("sum" , randomIntBetween (100 , 10000 ))
342+ .field ("value_count" , randomIntBetween (100 , 1000 ))
343+ .endObject ()
344+ .endObject ();
345+ };
346+ bulkIndex (sourceSupplier );
347+ prepareSourceIndex (sourceIndex , true );
348+ downsample (sourceIndex , downsampleIndex , config );
349+ assertDownsampleIndex (sourceIndex , downsampleIndex , config );
350+ }
351+
324352 public void testDownsampleIndexWithFlattenedAndMultiFieldDimensions () throws Exception {
325353 DownsampleConfig config = new DownsampleConfig (randomInterval ());
326354 SourceSupplier sourceSupplier = () -> {
0 commit comments