@@ -28,21 +28,23 @@ public KeywordFieldBlockLoaderTests(Params params) {
2828 @ SuppressWarnings ("unchecked" )
2929 @ Override
3030 protected Object expected (Map <String , Object > fieldMapping , Object value , TestContext testContext ) {
31- var nullValue = (String ) fieldMapping .get ("null_value" );
31+ String nullValue = (String ) fieldMapping .get ("null_value" );
3232
33- var ignoreAbove = fieldMapping .get ("ignore_above" ) == null
33+ int ignoreAbove = fieldMapping .get ("ignore_above" ) == null
3434 ? Integer .MAX_VALUE
3535 : ((Number ) fieldMapping .get ("ignore_above" )).intValue ();
3636
37+ String normalizerName = (String ) fieldMapping .get ("normalizer" );
38+
3739 if (value == null ) {
38- return convert (null , nullValue , ignoreAbove );
40+ return convert (null , nullValue , ignoreAbove , normalizerName );
3941 }
4042
4143 if (value instanceof String s ) {
42- return convert (s , nullValue , ignoreAbove );
44+ return convert (s , nullValue , ignoreAbove , normalizerName );
4345 }
4446
45- Function <Stream <String >, Stream <BytesRef >> convertValues = s -> s .map (v -> convert (v , nullValue , ignoreAbove ))
47+ Function <Stream <String >, Stream <BytesRef >> convertValues = s -> s .map (v -> convert (v , nullValue , ignoreAbove , normalizerName ))
4648 .filter (Objects ::nonNull );
4749
4850 boolean hasDocValues = hasDocValues (fieldMapping , false );
@@ -63,15 +65,21 @@ protected Object expected(Map<String, Object> fieldMapping, Object value, TestCo
6365 return maybeFoldList (resultList );
6466 }
6567
66- private BytesRef convert (String value , String nullValue , int ignoreAbove ) {
68+ private BytesRef convert (String value , String nullValue , int ignoreAbove , String normalizer ) {
6769 if (value == null ) {
6870 if (nullValue != null ) {
6971 value = nullValue ;
7072 } else {
7173 return null ;
7274 }
7375 }
74-
76+ if (Objects .equals (normalizer , "lowercase" )) {
77+ // hopefully not Turkish...
78+ value = value .toLowerCase ();
79+ } else if (normalizer != null ) {
80+ // we probably can't get here anyway, since MapperServiceTestCase only initializes the lowercase normalizer
81+ throw new IllegalArgumentException ("normalizer [" + normalizer + "] not supported for block loader tests" );
82+ }
7583 return value .length () <= ignoreAbove ? new BytesRef (value ) : null ;
7684 }
7785}
0 commit comments