@@ -1147,7 +1147,7 @@ public void testMultipleTypeMerges() throws IOException {
1147
1147
}""" , Strings .toString (mapperService .documentMapper ().mapping (), true , true ));
1148
1148
}
1149
1149
1150
- public void testPropertiesField () throws IOException {
1150
+ public void testPropertiesFieldSingleChildMerge () throws IOException {
1151
1151
CompressedXContent mapping1 = new CompressedXContent ("""
1152
1152
{
1153
1153
"properties": {
@@ -1238,6 +1238,103 @@ public void testPropertiesField() throws IOException {
1238
1238
assertEquals ("keyword" , grandchildMapper .typeName ());
1239
1239
}
1240
1240
1241
+ public void testPropertiesFieldMultiChildMerge () throws IOException {
1242
+ CompressedXContent mapping1 = new CompressedXContent ("""
1243
+ {
1244
+ "properties": {
1245
+ "properties": {
1246
+ "properties": {
1247
+ "child1": {
1248
+ "type": "text",
1249
+ "fields": {
1250
+ "keyword": {
1251
+ "type": "keyword"
1252
+ }
1253
+ }
1254
+ },
1255
+ "child2": {
1256
+ "type": "text"
1257
+ },
1258
+ "child3": {
1259
+ "properties": {
1260
+ "grandchild": {
1261
+ "type": "text"
1262
+ }
1263
+ }
1264
+ }
1265
+ }
1266
+ }
1267
+ }
1268
+ }""" );
1269
+
1270
+ CompressedXContent mapping2 = new CompressedXContent ("""
1271
+ {
1272
+ "properties": {
1273
+ "properties": {
1274
+ "properties": {
1275
+ "child2": {
1276
+ "type": "integer"
1277
+ },
1278
+ "child3": {
1279
+ "properties": {
1280
+ "grandchild": {
1281
+ "type": "long"
1282
+ }
1283
+ }
1284
+ }
1285
+ }
1286
+ }
1287
+ }
1288
+ }""" );
1289
+
1290
+ MapperService mapperService = createMapperService (mapping (b -> {}));
1291
+ mapperService .merge ("_doc" , List .of (mapping1 , mapping2 ), MergeReason .INDEX_TEMPLATE );
1292
+ assertEquals ("""
1293
+ {
1294
+ "_doc" : {
1295
+ "properties" : {
1296
+ "properties" : {
1297
+ "properties" : {
1298
+ "child1" : {
1299
+ "type" : "text",
1300
+ "fields" : {
1301
+ "keyword" : {
1302
+ "type" : "keyword"
1303
+ }
1304
+ }
1305
+ },
1306
+ "child2" : {
1307
+ "type" : "integer"
1308
+ },
1309
+ "child3" : {
1310
+ "properties" : {
1311
+ "grandchild" : {
1312
+ "type" : "long"
1313
+ }
1314
+ }
1315
+ }
1316
+ }
1317
+ }
1318
+ }
1319
+ }
1320
+ }""" , Strings .toString (mapperService .documentMapper ().mapping (), true , true ));
1321
+
1322
+ Mapper propertiesMapper = mapperService .documentMapper ().mapping ().getRoot ().getMapper ("properties" );
1323
+ assertThat (propertiesMapper , instanceOf (ObjectMapper .class ));
1324
+ Mapper childMapper = ((ObjectMapper ) propertiesMapper ).getMapper ("child1" );
1325
+ assertThat (childMapper , instanceOf (FieldMapper .class ));
1326
+ assertEquals ("text" , childMapper .typeName ());
1327
+ assertEquals (2 , childMapper .getTotalFieldsCount ());
1328
+ childMapper = ((ObjectMapper ) propertiesMapper ).getMapper ("child2" );
1329
+ assertThat (childMapper , instanceOf (FieldMapper .class ));
1330
+ assertEquals ("integer" , childMapper .typeName ());
1331
+ assertEquals (1 , childMapper .getTotalFieldsCount ());
1332
+ childMapper = ((ObjectMapper ) propertiesMapper ).getMapper ("child3" );
1333
+ assertThat (childMapper , instanceOf (ObjectMapper .class ));
1334
+ Mapper grandchildMapper = ((ObjectMapper ) childMapper ).getMapper ("grandchild" );
1335
+ assertEquals ("long" , grandchildMapper .typeName ());
1336
+ }
1337
+
1241
1338
public void testMergeUntilLimit () throws IOException {
1242
1339
CompressedXContent mapping1 = new CompressedXContent ("""
1243
1340
{
0 commit comments