37
37
import java .util .Collection ;
38
38
import java .util .Date ;
39
39
import java .util .HashMap ;
40
- import java .util .HashSet ;
41
40
import java .util .Map ;
42
- import java .util .Set ;
43
41
44
42
import org .elasticsearch .search .suggest .completion .context .ContextMapping ;
45
43
import org .json .JSONException ;
@@ -420,7 +418,7 @@ public void shouldSetFieldMappingProperties() throws JSONException {
420
418
String mapping = getMappingBuilder ().buildPropertyMapping (FieldMappingParameters .class );
421
419
422
420
// then
423
- assertEquals (expected , mapping , true );
421
+ assertEquals (expected , mapping , false );
424
422
}
425
423
426
424
@ Test
@@ -439,7 +437,7 @@ void shouldWriteDynamicMappingSettings() throws JSONException {
439
437
440
438
String mapping = getMappingBuilder ().buildPropertyMapping (ConfigureDynamicMappingEntity .class );
441
439
442
- assertEquals (expected , mapping , true );
440
+ assertEquals (expected , mapping , false );
443
441
}
444
442
445
443
@ Test // DATAES-784
@@ -454,7 +452,7 @@ void shouldMapPropertyObjectsToFieldDefinition() throws JSONException {
454
452
455
453
String mapping = getMappingBuilder ().buildPropertyMapping (ValueDoc .class );
456
454
457
- assertEquals (expected , mapping , true );
455
+ assertEquals (expected , mapping , false );
458
456
}
459
457
460
458
@ Test // DATAES-788
@@ -568,6 +566,54 @@ void shouldOnlyAllowDisabledPropertiesOnTypeObject() {
568
566
.isInstanceOf (MappingException .class );
569
567
}
570
568
569
+ @ Test // #1711
570
+ @ DisplayName ("should write typeHint entries" )
571
+ void shouldWriteTypeHintEntries () throws JSONException {
572
+
573
+ String expected = "{\n " + //
574
+ " \" properties\" : {\n " + //
575
+ " \" _class\" : {\n " + //
576
+ " \" type\" : \" keyword\" ,\n " + //
577
+ " \" index\" : false,\n " + //
578
+ " \" doc_values\" : false\n " + //
579
+ " },\n " + //
580
+ " \" id\" : {\n " + //
581
+ " \" type\" : \" keyword\" \n " + //
582
+ " },\n " + //
583
+ " \" nestedEntity\" : {\n " + //
584
+ " \" type\" : \" nested\" ,\n " + //
585
+ " \" properties\" : {\n " + //
586
+ " \" _class\" : {\n " + //
587
+ " \" type\" : \" keyword\" ,\n " + //
588
+ " \" index\" : false,\n " + //
589
+ " \" doc_values\" : false\n " + //
590
+ " },\n " + //
591
+ " \" nestedField\" : {\n " + //
592
+ " \" type\" : \" text\" \n " + //
593
+ " }\n " + //
594
+ " }\n " + //
595
+ " },\n " + //
596
+ " \" objectEntity\" : {\n " + //
597
+ " \" type\" : \" object\" ,\n " + //
598
+ " \" properties\" : {\n " + //
599
+ " \" _class\" : {\n " + //
600
+ " \" type\" : \" keyword\" ,\n " + //
601
+ " \" index\" : false,\n " + //
602
+ " \" doc_values\" : false\n " + //
603
+ " },\n " + //
604
+ " \" objectField\" : {\n " + //
605
+ " \" type\" : \" text\" \n " + //
606
+ " }\n " + //
607
+ " }\n " + //
608
+ " }\n " + //
609
+ " }\n " + //
610
+ "}\n " ; //
611
+
612
+ String mapping = getMappingBuilder ().buildPropertyMapping (TypeHintEntity .class );
613
+
614
+ assertEquals (expected , mapping , false );
615
+ }
616
+
571
617
@ Setter
572
618
@ Getter
573
619
@ NoArgsConstructor
@@ -862,21 +908,6 @@ static class GeoEntity {
862
908
orientation = GeoShapeField .Orientation .clockwise ) private String shape2 ;
863
909
}
864
910
865
- @ Document (indexName = "test-index-user-mapping-builder" )
866
- static class User {
867
- @ Nullable @ Id private String id ;
868
-
869
- @ Field (type = FieldType .Nested , ignoreFields = { "users" }) private Set <Group > groups = new HashSet <>();
870
- }
871
-
872
- @ Document (indexName = "test-index-group-mapping-builder" )
873
- static class Group {
874
-
875
- @ Nullable @ Id String id ;
876
-
877
- @ Field (type = FieldType .Nested , ignoreFields = { "groups" }) private Set <User > users = new HashSet <>();
878
- }
879
-
880
911
@ Document (indexName = "test-index-field-mapping-parameters" )
881
912
static class FieldMappingParameters {
882
913
@ Nullable @ Field private String indexTrue ;
@@ -1008,4 +1039,25 @@ static class DisabledMappingProperty {
1008
1039
@ Field (type = Text ) private String text ;
1009
1040
@ Mapping (enabled = false ) @ Field (type = Object ) private Object object ;
1010
1041
}
1042
+
1043
+ @ Data
1044
+ @ AllArgsConstructor
1045
+ @ NoArgsConstructor
1046
+ static class TypeHintEntity {
1047
+ @ Id @ Field (type = Keyword ) private String id ;
1048
+
1049
+ @ Field (type = Nested ) private NestedEntity nestedEntity ;
1050
+
1051
+ @ Field (type = Object ) private ObjectEntity objectEntity ;
1052
+
1053
+ @ Data
1054
+ static class NestedEntity {
1055
+ @ Field (type = Text ) private String nestedField ;
1056
+ }
1057
+
1058
+ @ Data
1059
+ static class ObjectEntity {
1060
+ @ Field (type = Text ) private String objectField ;
1061
+ }
1062
+ }
1011
1063
}
0 commit comments