Skip to content

Commit c44acbd

Browse files
committed
Start switching to non-deprecated ParseField.match method
This commit switches all the modules and server test code to use the non-deprecated `ParseField.match` method, passing in the parser's deprecation handler or the logging deprecation handler when a parser is not available (like in tests). Relates to elastic#28449
1 parent bb97c00 commit c44acbd

File tree

12 files changed

+87
-75
lines changed

12 files changed

+87
-75
lines changed

modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public MatrixStatsParser() {
3939
@Override
4040
protected boolean token(String aggregationName, String currentFieldName, XContentParser.Token token, XContentParser parser,
4141
Map<ParseField, Object> otherOptions) throws IOException {
42-
if (MULTIVALUE_MODE_FIELD.match(currentFieldName)) {
42+
if (MULTIVALUE_MODE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
4343
if (token == XContentParser.Token.VALUE_STRING) {
4444
otherOptions.put(MULTIVALUE_MODE_FIELD, parser.text());
4545
return true;

modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceParser.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ private MultiValuesSourceParser(boolean formattable, ValuesSourceType valuesSour
8888
if (token == XContentParser.Token.FIELD_NAME) {
8989
currentFieldName = parser.currentName();
9090
} else if (token == XContentParser.Token.VALUE_STRING) {
91-
if (CommonFields.FIELDS.match(currentFieldName)) {
91+
if (CommonFields.FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {
9292
fields = Collections.singletonList(parser.text());
93-
} else if (formattable && CommonFields.FORMAT.match(currentFieldName)) {
93+
} else if (formattable && CommonFields.FORMAT.match(currentFieldName, parser.getDeprecationHandler())) {
9494
format = parser.text();
95-
} else if (CommonFields.VALUE_TYPE.match(currentFieldName)) {
95+
} else if (CommonFields.VALUE_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
9696
throw new ParsingException(parser.getTokenLocation(),
9797
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "]. " +
9898
"Multi-field aggregations do not support scripts.");
@@ -101,12 +101,12 @@ private MultiValuesSourceParser(boolean formattable, ValuesSourceType valuesSour
101101
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "].");
102102
}
103103
} else if (token == XContentParser.Token.START_OBJECT) {
104-
if (CommonFields.MISSING.match(currentFieldName)) {
104+
if (CommonFields.MISSING.match(currentFieldName, parser.getDeprecationHandler())) {
105105
missingMap = new HashMap<>();
106106
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
107107
parseMissingAndAdd(aggregationName, currentFieldName, parser, missingMap);
108108
}
109-
} else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
109+
} else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
110110
throw new ParsingException(parser.getTokenLocation(),
111111
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "]. " +
112112
"Multi-field aggregations do not support scripts.");
@@ -116,11 +116,11 @@ private MultiValuesSourceParser(boolean formattable, ValuesSourceType valuesSour
116116
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "].");
117117
}
118118
} else if (token == XContentParser.Token.START_ARRAY) {
119-
if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
119+
if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
120120
throw new ParsingException(parser.getTokenLocation(),
121121
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "]. " +
122122
"Multi-field aggregations do not support scripts.");
123-
} else if (CommonFields.FIELDS.match(currentFieldName)) {
123+
} else if (CommonFields.FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {
124124
fields = new ArrayList<>();
125125
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
126126
if (token == XContentParser.Token.VALUE_STRING) {

modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,27 +257,27 @@ public static HasChildQueryBuilder fromXContent(XContentParser parser) throws IO
257257
if (token == XContentParser.Token.FIELD_NAME) {
258258
currentFieldName = parser.currentName();
259259
} else if (token == XContentParser.Token.START_OBJECT) {
260-
if (QUERY_FIELD.match(currentFieldName)) {
260+
if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
261261
iqb = parseInnerQueryBuilder(parser);
262-
} else if (INNER_HITS_FIELD.match(currentFieldName)) {
262+
} else if (INNER_HITS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
263263
innerHitBuilder = InnerHitBuilder.fromXContent(parser);
264264
} else {
265265
throw new ParsingException(parser.getTokenLocation(), "[has_child] query does not support [" + currentFieldName + "]");
266266
}
267267
} else if (token.isValue()) {
268-
if (TYPE_FIELD.match(currentFieldName)) {
268+
if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
269269
childType = parser.text();
270-
} else if (SCORE_MODE_FIELD.match(currentFieldName)) {
270+
} else if (SCORE_MODE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
271271
scoreMode = NestedQueryBuilder.parseScoreMode(parser.text());
272-
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
272+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
273273
boost = parser.floatValue();
274-
} else if (MIN_CHILDREN_FIELD.match(currentFieldName)) {
274+
} else if (MIN_CHILDREN_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
275275
minChildren = parser.intValue(true);
276-
} else if (MAX_CHILDREN_FIELD.match(currentFieldName)) {
276+
} else if (MAX_CHILDREN_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
277277
maxChildren = parser.intValue(true);
278-
} else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) {
278+
} else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
279279
ignoreUnmapped = parser.booleanValue();
280-
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
280+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
281281
queryName = parser.text();
282282
} else {
283283
throw new ParsingException(parser.getTokenLocation(), "[has_child] query does not support [" + currentFieldName + "]");

modules/parent-join/src/main/java/org/elasticsearch/join/query/HasParentQueryBuilder.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,24 +295,24 @@ public static HasParentQueryBuilder fromXContent(XContentParser parser) throws I
295295
if (token == XContentParser.Token.FIELD_NAME) {
296296
currentFieldName = parser.currentName();
297297
} else if (token == XContentParser.Token.START_OBJECT) {
298-
if (QUERY_FIELD.match(currentFieldName)) {
298+
if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
299299
iqb = parseInnerQueryBuilder(parser);
300-
} else if (INNER_HITS_FIELD.match(currentFieldName)) {
300+
} else if (INNER_HITS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
301301
innerHits = InnerHitBuilder.fromXContent(parser);
302302
} else {
303303
throw new ParsingException(parser.getTokenLocation(),
304304
"[has_parent] query does not support [" + currentFieldName + "]");
305305
}
306306
} else if (token.isValue()) {
307-
if (TYPE_FIELD.match(currentFieldName)) {
307+
if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
308308
parentType = parser.text();
309-
} else if (SCORE_FIELD.match(currentFieldName)) {
309+
} else if (SCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
310310
score = parser.booleanValue();
311-
} else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) {
311+
} else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
312312
ignoreUnmapped = parser.booleanValue();
313-
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
313+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
314314
boost = parser.floatValue();
315-
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
315+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
316316
queryName = parser.text();
317317
} else {
318318
throw new ParsingException(parser.getTokenLocation(),

modules/parent-join/src/main/java/org/elasticsearch/join/query/ParentIdQueryBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ public static ParentIdQueryBuilder fromXContent(XContentParser parser) throws IO
132132
if (token == XContentParser.Token.FIELD_NAME) {
133133
currentFieldName = parser.currentName();
134134
} else if (token.isValue()) {
135-
if (TYPE_FIELD.match(currentFieldName)) {
135+
if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
136136
type = parser.text();
137-
} else if (ID_FIELD.match(currentFieldName)) {
137+
} else if (ID_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
138138
id = parser.text();
139-
} else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) {
139+
} else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
140140
ignoreUnmapped = parser.booleanValue();
141-
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
141+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
142142
boost = parser.floatValue();
143-
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
143+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
144144
queryName = parser.text();
145145
} else {
146146
throw new ParsingException(parser.getTokenLocation(), "[parent_id] query does not support [" + currentFieldName + "]");

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public static PercolateQueryBuilder fromXContent(XContentParser parser) throws I
403403
if (token == XContentParser.Token.FIELD_NAME) {
404404
currentFieldName = parser.currentName();
405405
} else if (token == XContentParser.Token.START_ARRAY) {
406-
if (DOCUMENTS_FIELD.match(currentFieldName)) {
406+
if (DOCUMENTS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
407407
if (documentSpecified) {
408408
throw new IllegalArgumentException("[" + PercolateQueryBuilder.NAME +
409409
"] Either specified [document] or [documents], not both");
@@ -426,7 +426,7 @@ public static PercolateQueryBuilder fromXContent(XContentParser parser) throws I
426426
"] query does not field name [" + currentFieldName + "]");
427427
}
428428
} else if (token == XContentParser.Token.START_OBJECT) {
429-
if (DOCUMENT_FIELD.match(currentFieldName)) {
429+
if (DOCUMENT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
430430
if (documentsSpecified) {
431431
throw new IllegalArgumentException("[" + PercolateQueryBuilder.NAME +
432432
"] Either specified [document] or [documents], not both");
@@ -442,27 +442,27 @@ public static PercolateQueryBuilder fromXContent(XContentParser parser) throws I
442442
"] query does not support field name [" + currentFieldName + "]");
443443
}
444444
} else if (token.isValue() || token == XContentParser.Token.VALUE_NULL) {
445-
if (QUERY_FIELD.match(currentFieldName)) {
445+
if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
446446
field = parser.text();
447-
} else if (NAME_FIELD.match(currentFieldName)) {
447+
} else if (NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
448448
name = parser.textOrNull();
449-
} else if (DOCUMENT_TYPE_FIELD.match(currentFieldName)) {
449+
} else if (DOCUMENT_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
450450
documentType = parser.textOrNull();
451-
} else if (INDEXED_DOCUMENT_FIELD_INDEX.match(currentFieldName)) {
451+
} else if (INDEXED_DOCUMENT_FIELD_INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
452452
indexedDocumentIndex = parser.text();
453-
} else if (INDEXED_DOCUMENT_FIELD_TYPE.match(currentFieldName)) {
453+
} else if (INDEXED_DOCUMENT_FIELD_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
454454
indexedDocumentType = parser.text();
455-
} else if (INDEXED_DOCUMENT_FIELD_ID.match(currentFieldName)) {
455+
} else if (INDEXED_DOCUMENT_FIELD_ID.match(currentFieldName, parser.getDeprecationHandler())) {
456456
indexedDocumentId = parser.text();
457-
} else if (INDEXED_DOCUMENT_FIELD_ROUTING.match(currentFieldName)) {
457+
} else if (INDEXED_DOCUMENT_FIELD_ROUTING.match(currentFieldName, parser.getDeprecationHandler())) {
458458
indexedDocumentRouting = parser.text();
459-
} else if (INDEXED_DOCUMENT_FIELD_PREFERENCE.match(currentFieldName)) {
459+
} else if (INDEXED_DOCUMENT_FIELD_PREFERENCE.match(currentFieldName, parser.getDeprecationHandler())) {
460460
indexedDocumentPreference = parser.text();
461-
} else if (INDEXED_DOCUMENT_FIELD_VERSION.match(currentFieldName)) {
461+
} else if (INDEXED_DOCUMENT_FIELD_VERSION.match(currentFieldName, parser.getDeprecationHandler())) {
462462
indexedDocumentVersion = parser.longValue();
463-
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
463+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
464464
boost = parser.floatValue();
465-
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
465+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
466466
queryName = parser.text();
467467
} else {
468468
throw new ParsingException(parser.getTokenLocation(), "[" + PercolateQueryBuilder.NAME +

modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.action.search.SearchRequest;
2424
import org.elasticsearch.client.node.NodeClient;
2525
import org.elasticsearch.common.settings.Settings;
26+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
2627
import org.elasticsearch.rest.RestController;
2728
import org.elasticsearch.rest.RestRequest;
2829
import org.elasticsearch.script.Script;
@@ -91,26 +92,26 @@ private static Script parseScript(Object config) {
9192
Map.Entry<String, Object> entry = itr.next();
9293
String parameterName = entry.getKey();
9394
Object parameterValue = entry.getValue();
94-
if (Script.LANG_PARSE_FIELD.match(parameterName)) {
95+
if (Script.LANG_PARSE_FIELD.match(parameterName, LoggingDeprecationHandler.INSTANCE)) {
9596
if (parameterValue instanceof String || parameterValue == null) {
9697
lang = (String) parameterValue;
9798
} else {
9899
throw new ElasticsearchParseException("Value must be of type String: [" + parameterName + "]");
99100
}
100-
} else if (Script.PARAMS_PARSE_FIELD.match(parameterName)) {
101+
} else if (Script.PARAMS_PARSE_FIELD.match(parameterName, LoggingDeprecationHandler.INSTANCE)) {
101102
if (parameterValue instanceof Map || parameterValue == null) {
102103
params = (Map<String, Object>) parameterValue;
103104
} else {
104105
throw new ElasticsearchParseException("Value must be of type String: [" + parameterName + "]");
105106
}
106-
} else if (ScriptType.INLINE.getParseField().match(parameterName)) {
107+
} else if (ScriptType.INLINE.getParseField().match(parameterName, LoggingDeprecationHandler.INSTANCE)) {
107108
if (parameterValue instanceof String || parameterValue == null) {
108109
script = (String) parameterValue;
109110
type = ScriptType.INLINE;
110111
} else {
111112
throw new ElasticsearchParseException("Value must be of type String: [" + parameterName + "]");
112113
}
113-
} else if (ScriptType.STORED.getParseField().match(parameterName)) {
114+
} else if (ScriptType.STORED.getParseField().match(parameterName, LoggingDeprecationHandler.INSTANCE)) {
114115
if (parameterValue instanceof String || parameterValue == null) {
115116
script = (String) parameterValue;
116117
type = ScriptType.STORED;

0 commit comments

Comments
 (0)