|
64 | 64 | import static org.hamcrest.Matchers.greaterThan; |
65 | 65 | import static org.hamcrest.Matchers.hasSize; |
66 | 66 | import static org.hamcrest.Matchers.instanceOf; |
| 67 | +import static org.junit.Assert.assertFalse; |
| 68 | +import static org.junit.Assert.assertTrue; |
67 | 69 |
|
68 | 70 | public class KeywordFieldMapperTests extends MapperTestCase { |
69 | 71 |
|
@@ -1064,103 +1066,6 @@ public void testFieldTypeDefault_IndexedFalseDocValuesFalse() throws IOException |
1064 | 1066 | assertFalse(mapper.fieldType().hasDocValuesSkipper()); |
1065 | 1067 | } |
1066 | 1068 |
|
1067 | | - public void test_isIgnoreAboveSet_returns_true_when_ignore_above_is_provided() throws IOException { |
1068 | | - // given |
1069 | | - MapperService mapperService = createSytheticSourceMapperService(mapping(b -> { |
1070 | | - b.startObject("potato"); |
1071 | | - b.field("type", "keyword"); |
1072 | | - b.field("ignore_above", 123); |
1073 | | - b.endObject(); |
1074 | | - })); |
1075 | | - |
1076 | | - // when |
1077 | | - KeywordFieldMapper mapper = (KeywordFieldMapper) mapperService.documentMapper().mappers().getMapper("potato"); |
1078 | | - |
1079 | | - // then |
1080 | | - assertTrue(mapper.fieldType().ignoreAbove().isSet()); |
1081 | | - } |
1082 | | - |
1083 | | - public void test_isIgnoreAboveSet_returns_false_when_ignore_above_is_missing() throws IOException { |
1084 | | - // given |
1085 | | - MapperService mapperService = createSytheticSourceMapperService(mapping(b -> { |
1086 | | - b.startObject("potato"); |
1087 | | - b.field("type", "keyword"); |
1088 | | - b.endObject(); |
1089 | | - })); |
1090 | | - |
1091 | | - // when |
1092 | | - KeywordFieldMapper mapper = (KeywordFieldMapper) mapperService.documentMapper().mappers().getMapper("potato"); |
1093 | | - |
1094 | | - // then |
1095 | | - assertFalse(mapper.fieldType().ignoreAbove().isSet()); |
1096 | | - } |
1097 | | - |
1098 | | - public void test_value_is_not_ignored_when_it_exceeds_ignore_above_and_field_is_not_a_multi_field() throws IOException { |
1099 | | - // given |
1100 | | - MapperService mapperService = createSytheticSourceMapperService(mapping(b -> { |
1101 | | - b.startObject("potato"); |
1102 | | - b.field("type", "keyword"); |
1103 | | - b.field("ignore_above", 1); |
1104 | | - b.endObject(); |
1105 | | - })); |
1106 | | - |
1107 | | - // when |
1108 | | - KeywordFieldMapper mapper = (KeywordFieldMapper) mapperService.documentMapper().mappers().getMapper("potato"); |
1109 | | - |
1110 | | - // then |
1111 | | - assertFalse( |
1112 | | - mapper.fieldType() |
1113 | | - .ignoreAbove() |
1114 | | - .isIgnored("this value will trip ignore_above, but bc keyword is not a multi field this value will not be ignored") |
1115 | | - ); |
1116 | | - } |
1117 | | - |
1118 | | - public void test_value_is_ignored_when_it_exceeds_ignore_above_and_field_is_a_multi_field() throws IOException { |
1119 | | - // given |
1120 | | - MapperService mapperService = createSytheticSourceMapperService(mapping(b -> { |
1121 | | - b.startObject("potato").field("type", "text"); |
1122 | | - { |
1123 | | - b.startObject("fields"); |
1124 | | - { |
1125 | | - b.startObject("tomato").field("type", "keyword"); |
1126 | | - b.field("ignore_above", 1); |
1127 | | - b.endObject(); |
1128 | | - } |
1129 | | - b.endObject(); |
1130 | | - } |
1131 | | - b.endObject(); |
1132 | | - })); |
1133 | | - |
1134 | | - // when |
1135 | | - KeywordFieldMapper mapper = (KeywordFieldMapper) mapperService.documentMapper().mappers().getMapper("potato.tomato"); |
1136 | | - |
1137 | | - // then |
1138 | | - assertTrue(mapper.fieldType().ignoreAbove().isIgnored("this value is too long and will be ignored")); |
1139 | | - } |
1140 | | - |
1141 | | - public void test_value_is_not_ignored_when_it_does_not_exceed_ignore_above_and_field_is_a_multi_field() throws IOException { |
1142 | | - // given |
1143 | | - MapperService mapperService = createSytheticSourceMapperService(mapping(b -> { |
1144 | | - b.startObject("potato").field("type", "text"); |
1145 | | - { |
1146 | | - b.startObject("fields"); |
1147 | | - { |
1148 | | - b.startObject("tomato").field("type", "keyword"); |
1149 | | - b.field("ignore_above", 123); |
1150 | | - b.endObject(); |
1151 | | - } |
1152 | | - b.endObject(); |
1153 | | - } |
1154 | | - b.endObject(); |
1155 | | - })); |
1156 | | - |
1157 | | - // when |
1158 | | - KeywordFieldMapper mapper = (KeywordFieldMapper) mapperService.documentMapper().mappers().getMapper("potato.tomato"); |
1159 | | - |
1160 | | - // then |
1161 | | - assertFalse(mapper.fieldType().ignoreAbove().isIgnored("this value is too short to be ignored")); |
1162 | | - } |
1163 | | - |
1164 | 1069 | public void test_value_is_stored_when_it_exceeds_ignore_above_and_field_is_not_a_multi_field() throws IOException { |
1165 | 1070 | // given |
1166 | 1071 | MapperService mapperService = createSytheticSourceMapperService(mapping(b -> { |
@@ -1207,32 +1112,6 @@ public void test_value_is_not_stored_when_it_exceeds_ignore_above_and_field_is_a |
1207 | 1112 | assertThat(doc.rootDoc().getField(mapper.fieldType().syntheticSourceFallbackFieldName()), Matchers.nullValue()); |
1208 | 1113 | } |
1209 | 1114 |
|
1210 | | - public void test_value_does_not_exceed_ignore_above_and_field_is_a_multi_field() throws IOException { |
1211 | | - // given |
1212 | | - MapperService mapperService = createSytheticSourceMapperService(mapping(b -> { |
1213 | | - b.startObject("potato").field("type", "text"); |
1214 | | - { |
1215 | | - b.startObject("fields"); |
1216 | | - { |
1217 | | - b.startObject("tomato").field("type", "keyword"); |
1218 | | - b.field("ignore_above", 123); |
1219 | | - b.endObject(); |
1220 | | - } |
1221 | | - b.endObject(); |
1222 | | - } |
1223 | | - b.endObject(); |
1224 | | - })); |
1225 | | - |
1226 | | - // when |
1227 | | - KeywordFieldMapper mapper = (KeywordFieldMapper) mapperService.documentMapper().mappers().getMapper("potato.tomato"); |
1228 | | - ParsedDocument doc = mapperService.documentMapper().parse(source(b -> { b.field("potato", "this value is short"); })); |
1229 | | - |
1230 | | - // then |
1231 | | - |
1232 | | - // we don't expect to store anything extra when ignore_above isn't tripped as we can rely on doc_values for source |
1233 | | - assertThat(doc.rootDoc().getField(mapper.fieldType().syntheticSourceFallbackFieldName()), Matchers.nullValue()); |
1234 | | - } |
1235 | | - |
1236 | 1115 | public void test_value_exceeds_ignore_above_when_synthetic_source_disabled() throws IOException { |
1237 | 1116 | // given |
1238 | 1117 | final MapperService mapperService = createMapperService(mapping(b -> { |
|
0 commit comments