@@ -645,18 +645,38 @@ public void testCopyFromMultiField() {
645645 assertThat (e .getMessage (), Matchers .containsString ("[copy_to] may not be used to copy from a multi-field: [field.bar]" ));
646646 }
647647
648- public void testCopyToNonExistentField () {
649- Exception e = expectThrows (IllegalArgumentException .class , () -> createDocumentMapper (fieldMapping (b -> {
650- b .startObject ("test_field" );
648+ public void testCopyToNonExistentFieldDynamicFalse () {
649+ Exception e = expectThrows (IllegalArgumentException .class , () -> createDocumentMapper (topMapping (b -> {
650+ b .field ("dynamic" , "false" );
651+ b .startObject ("properties" );
651652 {
652- b .field ("type" , "text" );
653- b .array ("copy_to" , "missing_field" );
653+ b .startObject ("test_field" );
654+ {
655+ b .field ("type" , "text" );
656+ b .field ("copy_to" , "missing_field" );
657+ }
658+ b .endObject ();
654659 }
655660 b .endObject ();
656661 })));
657662 assertThat (e .getMessage (), Matchers .containsString ("Cannot copy to field [missing_field] since it is a non existent field" ));
658663 }
659664
665+ public void testCopyToNonExistentFieldDynamicTrue () throws IOException {
666+ DocumentMapper mapper = createDocumentMapper (topMapping (b -> {
667+ b .field ("dynamic" , "true" );
668+ b .startObject ("properties" );
669+ {
670+ b .startObject ("test_field" );
671+ {
672+ b .field ("type" , "text" );
673+ b .field ("copy_to" , "missing_field" );
674+ }
675+ b .endObject ();
676+ }
677+ b .endObject ();}));
678+ }
679+
660680 public void testCopyToDateRangeFailure () throws Exception {
661681 DocumentMapper docMapper = createDocumentMapper (topMapping (b -> {
662682 b .startObject ("properties" );
0 commit comments