@@ -35,20 +35,20 @@ protected Object expected(Map<String, Object> fieldMapping, Object value, TestCo
35
35
var fields = (Map <String , Object >) fieldMapping .get ("fields" );
36
36
if (fields != null ) {
37
37
var keywordMultiFieldMapping = (Map <String , Object >) fields .get ("kwd" );
38
+ Object normalizer = fields .get ("normalizer" );
38
39
boolean docValues = hasDocValues (keywordMultiFieldMapping , true );
39
- boolean index = keywordMultiFieldMapping .getOrDefault ("index" , true ).equals (true );
40
40
boolean store = keywordMultiFieldMapping .getOrDefault ("store" , false ).equals (true );
41
41
Object ignoreAbove = keywordMultiFieldMapping .get ("ignore_above" );
42
42
43
- // See TextFieldMapper.SyntheticSourceHelper#usingSyntheticSourceDelegate
43
+ // See TextFieldMapper.SyntheticSourceHelper#getKeywordFieldMapperForSyntheticSource
44
44
// and TextFieldMapper#canUseSyntheticSourceDelegateForLoading().
45
- boolean usingSyntheticSourceDelegate = docValues || store ;
46
- boolean canUseSyntheticSourceDelegateForLoading = usingSyntheticSourceDelegate && ignoreAbove == null && ( index || store ) ;
45
+ boolean usingSyntheticSourceDelegate = normalizer == null && ( docValues || store ) ;
46
+ boolean canUseSyntheticSourceDelegateForLoading = usingSyntheticSourceDelegate && ignoreAbove == null ;
47
47
if (canUseSyntheticSourceDelegateForLoading ) {
48
48
return KeywordFieldBlockLoaderTests .expectedValue (keywordMultiFieldMapping , value , params , testContext );
49
49
}
50
50
51
- // Even if multi- field is not eligible for loading it can still be used to produce synthetic source
51
+ // Even if multi field is not eligible for loading it can still be used to produce synthetic source
52
52
// and then we load from the synthetic source.
53
53
// Synthetic source is actually different from keyword field block loader results
54
54
// because synthetic source includes values exceeding ignore_above and block loader doesn't.
@@ -66,9 +66,7 @@ protected Object expected(Map<String, Object> fieldMapping, Object value, TestCo
66
66
boolean textFieldIndexed = (boolean ) fieldMapping .getOrDefault ("index" , true );
67
67
68
68
if (value == null ) {
69
- if (textFieldIndexed == false
70
- && nullValue != null
71
- && (ignoreAbove == null || nullValue .length () <= (int ) ignoreAbove )) {
69
+ if (textFieldIndexed == false && nullValue != null && nullValue .length () <= (int ) ignoreAbove ) {
72
70
return new BytesRef (nullValue );
73
71
}
74
72
@@ -89,7 +87,7 @@ protected Object expected(Map<String, Object> fieldMapping, Object value, TestCo
89
87
var indexed = values .stream ()
90
88
.map (s -> s == null ? nullValue : s )
91
89
.filter (Objects ::nonNull )
92
- .filter (s -> ignoreAbove == null || s .length () <= (int ) ignoreAbove )
90
+ .filter (s -> s .length () <= (int ) ignoreAbove )
93
91
.map (BytesRef ::new )
94
92
.collect (Collectors .toList ());
95
93
@@ -100,22 +98,20 @@ protected Object expected(Map<String, Object> fieldMapping, Object value, TestCo
100
98
}
101
99
102
100
// ignored values always come last
103
- List <BytesRef > ignored = ignoreAbove == null
104
- ? List .of ()
105
- : values .stream ()
106
- .map (s -> s == null ? nullValue : s )
107
- .filter (Objects ::nonNull )
108
- .filter (s -> s .length () > (int ) ignoreAbove )
109
- .map (BytesRef ::new )
110
- .toList ();
101
+ List <BytesRef > ignored = values .stream ()
102
+ .map (s -> s == null ? nullValue : s )
103
+ .filter (Objects ::nonNull )
104
+ .filter (s -> s .length () > (int ) ignoreAbove )
105
+ .map (BytesRef ::new )
106
+ .toList ();
111
107
112
108
indexed .addAll (ignored );
113
109
114
110
return maybeFoldList (indexed );
115
111
}
116
112
}
117
113
118
- // Loading from _ignored_source or stored _source
114
+ // Loading from stored field, _ignored_source or stored _source
119
115
return valuesInSourceOrder (value );
120
116
}
121
117
0 commit comments