27
27
import org .elasticsearch .common .io .stream .StreamInput ;
28
28
import org .elasticsearch .common .io .stream .StreamOutput ;
29
29
import org .elasticsearch .common .io .stream .Writeable ;
30
+ import org .elasticsearch .common .logging .DeprecationLogger ;
31
+ import org .elasticsearch .common .logging .Loggers ;
30
32
import org .elasticsearch .common .xcontent .ToXContent ;
31
33
import org .elasticsearch .common .xcontent .XContentBuilder ;
32
34
import org .elasticsearch .common .xcontent .XContentParser ;
45
47
*/
46
48
public class FetchSourceContext implements Writeable , ToXContent {
47
49
50
+ private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger (Loggers .getLogger (ParseField .class ));
51
+
48
52
public static final ParseField INCLUDES_FIELD = new ParseField ("includes" , "include" );
49
53
public static final ParseField EXCLUDES_FIELD = new ParseField ("excludes" , "exclude" );
50
54
@@ -148,7 +152,7 @@ public static FetchSourceContext fromXContent(XContentParser parser, ParseFieldM
148
152
if (token == XContentParser .Token .FIELD_NAME ) {
149
153
currentFieldName = parser .currentName ();
150
154
} else if (token == XContentParser .Token .START_ARRAY ) {
151
- if (parseFieldMatcher . match (currentFieldName , INCLUDES_FIELD )) {
155
+ if ("includes" . equals (currentFieldName ) || "include" . equals ( currentFieldName )) {
152
156
List <String > includesList = new ArrayList <>();
153
157
while ((token = parser .nextToken ()) != XContentParser .Token .END_ARRAY ) {
154
158
if (token == XContentParser .Token .VALUE_STRING ) {
@@ -159,6 +163,9 @@ public static FetchSourceContext fromXContent(XContentParser parser, ParseFieldM
159
163
}
160
164
}
161
165
includes = includesList .toArray (new String [includesList .size ()]);
166
+ if ("include" .equals (currentFieldName )){
167
+ DEPRECATION_LOGGER .deprecated ("Deprecated field [include] used, expected [includes] instead" );
168
+ }
162
169
} else if (parseFieldMatcher .match (currentFieldName , EXCLUDES_FIELD )) {
163
170
List <String > excludesList = new ArrayList <>();
164
171
while ((token = parser .nextToken ()) != XContentParser .Token .END_ARRAY ) {
@@ -175,8 +182,11 @@ public static FetchSourceContext fromXContent(XContentParser parser, ParseFieldM
175
182
+ " in [" + currentFieldName + "]." , parser .getTokenLocation ());
176
183
}
177
184
} else if (token == XContentParser .Token .VALUE_STRING ) {
178
- if (parseFieldMatcher . match (currentFieldName , INCLUDES_FIELD )) {
185
+ if ("includes" . equals (currentFieldName ) || "include" . equals ( currentFieldName )) {
179
186
includes = new String [] {parser .text ()};
187
+ if ("include" .equals (currentFieldName )){
188
+ DEPRECATION_LOGGER .deprecated ("Deprecated field [include] used, expected [includes] instead" );
189
+ }
180
190
} else if (parseFieldMatcher .match (currentFieldName , EXCLUDES_FIELD )) {
181
191
excludes = new String [] {parser .text ()};
182
192
} else {
0 commit comments