@@ -2593,6 +2593,59 @@ public void testComposableTemplateWithSubobjectsFalse() throws Exception {
2593
2593
);
2594
2594
}
2595
2595
2596
+ public void testComposableTemplateWithSubobjectsFalseObjectAndSubfield () throws Exception {
2597
+ MetadataIndexTemplateService service = getMetadataIndexTemplateService ();
2598
+ ClusterState state = ClusterState .EMPTY_STATE ;
2599
+
2600
+ ComponentTemplate subobjects = new ComponentTemplate (new Template (null , new CompressedXContent ("""
2601
+ {
2602
+ "properties": {
2603
+ "foo": {
2604
+ "type": "object",
2605
+ "subobjects": false
2606
+ },
2607
+ "foo.bar": {
2608
+ "type": "keyword"
2609
+ }
2610
+ }
2611
+ }
2612
+ """ ), null ), null , null );
2613
+
2614
+ state = service .addComponentTemplate (state , true , "subobjects" , subobjects );
2615
+ ComposableIndexTemplate it = ComposableIndexTemplate .builder ()
2616
+ .indexPatterns (List .of ("test-*" ))
2617
+ .template (new Template (null , null , null ))
2618
+ .componentTemplates (List .of ("subobjects" , "field_mapping" ))
2619
+ .priority (0L )
2620
+ .version (1L )
2621
+ .build ();
2622
+ state = service .addIndexTemplateV2 (state , true , "composable-template" , it );
2623
+
2624
+ List <CompressedXContent > mappings = MetadataIndexTemplateService .collectMappings (state , "composable-template" , "test-index" );
2625
+
2626
+ assertNotNull (mappings );
2627
+ assertThat (mappings .size (), equalTo (1 ));
2628
+ List <Map <String , Object >> parsedMappings = mappings .stream ().map (m -> {
2629
+ try {
2630
+ return MapperService .parseMapping (NamedXContentRegistry .EMPTY , m );
2631
+ } catch (Exception e ) {
2632
+ logger .error (e );
2633
+ fail ("failed to parse mappings: " + m .string ());
2634
+ return null ;
2635
+ }
2636
+ }).toList ();
2637
+
2638
+ assertThat (
2639
+ parsedMappings .get (0 ),
2640
+ equalTo (
2641
+ Map .of (
2642
+ "_doc" ,
2643
+ Map .of ("properties" , Map .of ("foo.bar" , Map .of ("type" , "keyword" ), "foo" , Map .of ("type" , "object" , "subobjects" , false )))
2644
+ )
2645
+ )
2646
+ );
2647
+ }
2648
+
2596
2649
public void testAddIndexTemplateWithDeprecatedComponentTemplate () throws Exception {
2597
2650
ClusterState state = ClusterState .EMPTY_STATE ;
2598
2651
final MetadataIndexTemplateService service = getMetadataIndexTemplateService ();
0 commit comments