Currently, when an object is mapped with `subobjects: false`, trying to ingest a document that has nested objects leads to a mapping exception.

In a couple of occasions, we've been talking about that it would be convenient if Elasticsearch could automatically flatten the fields instead of the client having to know about the `subobjects` setting. This would make `subobjects: false` more of a drop-in replacement that allows for a much easier adoption, without changes in the client.

Note that the `_source` should ideally stay untouched, just the stored fields should be flattened automatically.

Some related issues
* https://github.com/elastic/apm/issues/347
* https://github.com/elastic/elasticsearch/issues/88777
* https://github.com/elastic/package-spec/issues/349
server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java
"[1:44] failed to parse field [foo] of type [long] in a time series document at "
                        + "[2021-04-28T00:01:00.000Z]. Preview of field's value: 'true'"
                )
            );
        }
    }
    public void testMergeSubfieldWhileBuildingMappers() throws Exception {
        MapperService mapperService = createMapperService();
        /*
        We had a bug (https://github.com/elastic/elasticsearch/issues/88573) building an object mapper (ObjectMapper.Builder#buildMappers).
        A sub-field that already exists is merged with the existing one. As a result, the leaf field would get the wrong field path
        (missing the first portion of its path). The only way to trigger this scenario for dynamic mappings is to either allow duplicate
        JSON keys or ingest the same field with dots collapsed as well as expanded within the same document. Note that the two fields with
        same name need to be part  of the same mappings (hence the same document). If they are in two distinct mappings they are properly
        merged as part of RootObjectMapper#merge.
         */
        ParsedDocument doc = mapperService.documentMapper().parse(source("""
            {
              "foo" : {
                "bar" : {
                  "baz" : 1
                }
              },
              "foo.bar.baz" : 2
            }
            """));
        Mapping mapping = doc.dynamicMappingsUpdate();
        assertNotNull(mapping);
        Mapper fooMapper = mapping.getRoot().getMapper("foo");
        assertNotNull(fooMapper);