31
31
import java .util .Collection ;
32
32
import java .util .Date ;
33
33
import java .util .HashMap ;
34
+ import java .util .List ;
34
35
import java .util .Map ;
35
36
36
37
import org .elasticsearch .search .suggest .completion .context .ContextMapping ;
@@ -415,23 +416,42 @@ public void shouldSetFieldMappingProperties() throws JSONException {
415
416
assertEquals (expected , mapping , false );
416
417
}
417
418
418
- @ Test
419
+ @ Test // DATAES-148, #1767
419
420
void shouldWriteDynamicMappingSettings () throws JSONException {
420
421
421
422
String expected = "{\n " + //
422
- " \" dynamic\" : \" false\" ,\n " + //
423
- " \" properties\" : {\n " + //
424
- " \" author\" : {\n " + //
425
- " \" dynamic\" : \" strict\" ,\n " + //
426
- " \" type\" : \" object\" ,\n " + //
427
- " \" properties\" : {}\n " + //
423
+ " \" dynamic\" : \" false\" ,\n " + //
424
+ " \" properties\" : {\n " + //
425
+ " \" _class\" : {\n " + //
426
+ " \" type\" : \" keyword\" ,\n " + //
427
+ " \" index\" : false,\n " + //
428
+ " \" doc_values\" : false\n " + //
429
+ " },\n " + //
430
+ " \" author\" : {\n " + //
431
+ " \" type\" : \" object\" ,\n " + //
432
+ " \" dynamic\" : \" strict\" ,\n " + //
433
+ " \" properties\" : {\n " + //
434
+ " \" _class\" : {\n " + //
435
+ " \" type\" : \" keyword\" ,\n " + //
436
+ " \" index\" : false,\n " + //
437
+ " \" doc_values\" : false\n " + //
438
+ " }\n " + //
428
439
" }\n " + //
440
+ " },\n " + //
441
+ " \" objectMap\" : {\n " + //
442
+ " \" type\" : \" object\" ,\n " + //
443
+ " \" dynamic\" : \" false\" \n " + //
444
+ " },\n " + //
445
+ " \" nestedObjectMap\" : {\n " + //
446
+ " \" type\" : \" nested\" ,\n " + //
447
+ " \" dynamic\" : \" false\" \n " + //
429
448
" }\n " + //
430
- "}\n " ;
449
+ " }\n " + //
450
+ "}" ; //
431
451
432
452
String mapping = getMappingBuilder ().buildPropertyMapping (ConfigureDynamicMappingEntity .class );
433
453
434
- assertEquals (expected , mapping , false );
454
+ assertEquals (expected , mapping , true );
435
455
}
436
456
437
457
@ Test // DATAES-784
@@ -608,39 +628,38 @@ void shouldWriteTypeHintEntries() throws JSONException {
608
628
assertEquals (expected , mapping , false );
609
629
}
610
630
611
- @ Test // #1727
612
- @ DisplayName ("should map according to the annotated properties" )
613
- void shouldMapAccordingToTheAnnotatedProperties () throws JSONException {
614
-
615
- String expected = "{\n " +
616
- " \" properties\" : {\n " + //
617
- " \" field1\" : {\n " + //
618
- " \" type\" : \" date\" ,\n " + //
619
- " \" format\" : \" date_optional_time||epoch_millis\" \n " + //
620
- " },\n " + //
621
- " \" field2\" : {\n " + //
622
- " \" type\" : \" date\" ,\n " + //
623
- " \" format\" : \" basic_date\" \n " + //
624
- " },\n " + //
625
- " \" field3\" : {\n " + //
626
- " \" type\" : \" date\" ,\n " + //
627
- " \" format\" : \" basic_date||basic_time\" \n " + //
628
- " },\n " + //
629
- " \" field4\" : {\n " + //
630
- " \" type\" : \" date\" ,\n " + //
631
- " \" format\" : \" date_optional_time||epoch_millis||dd.MM.uuuu\" \n " + //
632
- " },\n " + //
633
- " \" field5\" : {\n " + //
634
- " \" type\" : \" date\" ,\n " + //
635
- " \" format\" : \" dd.MM.uuuu\" \n " + //
636
- " }\n " + //
637
- " }\n " + //
638
- "}" ; //
639
-
640
- String mapping = getMappingBuilder ().buildPropertyMapping (DateFormatsEntity .class );
641
-
642
- assertEquals (expected , mapping , false );
643
- }
631
+ @ Test // #1727
632
+ @ DisplayName ("should map according to the annotated properties" )
633
+ void shouldMapAccordingToTheAnnotatedProperties () throws JSONException {
634
+
635
+ String expected = "{\n " + " \" properties\" : {\n " + //
636
+ " \" field1\" : {\n " + //
637
+ " \" type\" : \" date\" ,\n " + //
638
+ " \" format\" : \" date_optional_time||epoch_millis\" \n " + //
639
+ " },\n " + //
640
+ " \" field2\" : {\n " + //
641
+ " \" type\" : \" date\" ,\n " + //
642
+ " \" format\" : \" basic_date\" \n " + //
643
+ " },\n " + //
644
+ " \" field3\" : {\n " + //
645
+ " \" type\" : \" date\" ,\n " + //
646
+ " \" format\" : \" basic_date||basic_time\" \n " + //
647
+ " },\n " + //
648
+ " \" field4\" : {\n " + //
649
+ " \" type\" : \" date\" ,\n " + //
650
+ " \" format\" : \" date_optional_time||epoch_millis||dd.MM.uuuu\" \n " + //
651
+ " },\n " + //
652
+ " \" field5\" : {\n " + //
653
+ " \" type\" : \" date\" ,\n " + //
654
+ " \" format\" : \" dd.MM.uuuu\" \n " + //
655
+ " }\n " + //
656
+ " }\n " + //
657
+ "}" ; //
658
+
659
+ String mapping = getMappingBuilder ().buildPropertyMapping (DateFormatsEntity .class );
660
+
661
+ assertEquals (expected , mapping , false );
662
+ }
644
663
645
664
@ Document (indexName = "ignore-above-index" )
646
665
static class IgnoreAboveEntity {
@@ -666,7 +685,6 @@ public void setMessage(@Nullable String message) {
666
685
}
667
686
}
668
687
669
-
670
688
static class FieldNameEntity {
671
689
672
690
@ Document (indexName = "fieldname-index" )
@@ -1199,6 +1217,10 @@ static class FieldMappingParameters {
1199
1217
static class ConfigureDynamicMappingEntity {
1200
1218
1201
1219
@ Nullable @ DynamicMapping (DynamicMappingValue .Strict ) @ Field (type = FieldType .Object ) private Author author ;
1220
+ @ Nullable @ DynamicMapping (DynamicMappingValue .False ) @ Field (
1221
+ type = FieldType .Object ) private Map <String , Object > objectMap ;
1222
+ @ Nullable @ DynamicMapping (DynamicMappingValue .False ) @ Field (
1223
+ type = FieldType .Nested ) private List <Map <String , Object >> nestedObjectMap ;
1202
1224
1203
1225
@ Nullable
1204
1226
public Author getAuthor () {
@@ -1474,7 +1496,8 @@ static class DateFormatsEntity {
1474
1496
@ Nullable @ Id private String id ;
1475
1497
@ Nullable @ Field (type = FieldType .Date ) private LocalDateTime field1 ;
1476
1498
@ Nullable @ Field (type = FieldType .Date , format = DateFormat .basic_date ) private LocalDateTime field2 ;
1477
- @ Nullable @ Field (type = FieldType .Date , format = { DateFormat .basic_date , DateFormat .basic_time }) private LocalDateTime field3 ;
1499
+ @ Nullable @ Field (type = FieldType .Date ,
1500
+ format = { DateFormat .basic_date , DateFormat .basic_time }) private LocalDateTime field3 ;
1478
1501
@ Nullable @ Field (type = FieldType .Date , pattern = "dd.MM.uuuu" ) private LocalDateTime field4 ;
1479
1502
@ Nullable @ Field (type = FieldType .Date , format = {}, pattern = "dd.MM.uuuu" ) private LocalDateTime field5 ;
1480
1503
0 commit comments