Skip to content

Commit 45d010e

Browse files
committed
Remove some usages of ParseFieldMatcher in favour of using ParseField directly
Relates to #19552 Relates to #22130
1 parent eaefb5f commit 45d010e

19 files changed

+113
-113
lines changed

core/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public DFB fromXContent(QueryParseContext context) throws IOException, ParsingEx
112112
XContentBuilder builder = XContentFactory.jsonBuilder();
113113
builder.copyCurrentStructure(parser);
114114
functionBytes = builder.bytes();
115-
} else if (context.getParseFieldMatcher().match(currentFieldName, MULTI_VALUE_MODE)) {
115+
} else if (MULTI_VALUE_MODE.match(currentFieldName)) {
116116
multiValueMode = MultiValueMode.fromString(parser.text());
117117
} else {
118118
throw new ParsingException(parser.getTokenLocation(), "malformed score function score parameters.");

core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregationBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,21 @@ public static FiltersAggregationBuilder parse(String aggregationName, QueryParse
217217
if (token == XContentParser.Token.FIELD_NAME) {
218218
currentFieldName = parser.currentName();
219219
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
220-
if (context.getParseFieldMatcher().match(currentFieldName, OTHER_BUCKET_FIELD)) {
220+
if (OTHER_BUCKET_FIELD.match(currentFieldName)) {
221221
otherBucket = parser.booleanValue();
222222
} else {
223223
throw new ParsingException(parser.getTokenLocation(),
224224
"Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].");
225225
}
226226
} else if (token == XContentParser.Token.VALUE_STRING) {
227-
if (context.getParseFieldMatcher().match(currentFieldName, OTHER_BUCKET_KEY_FIELD)) {
227+
if (OTHER_BUCKET_KEY_FIELD.match(currentFieldName)) {
228228
otherBucketKey = parser.text();
229229
} else {
230230
throw new ParsingException(parser.getTokenLocation(),
231231
"Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].");
232232
}
233233
} else if (token == XContentParser.Token.START_OBJECT) {
234-
if (context.getParseFieldMatcher().match(currentFieldName, FILTERS_FIELD)) {
234+
if (FILTERS_FIELD.match(currentFieldName)) {
235235
keyedFilters = new ArrayList<>();
236236
String key = null;
237237
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
@@ -247,7 +247,7 @@ public static FiltersAggregationBuilder parse(String aggregationName, QueryParse
247247
"Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].");
248248
}
249249
} else if (token == XContentParser.Token.START_ARRAY) {
250-
if (context.getParseFieldMatcher().match(currentFieldName, FILTERS_FIELD)) {
250+
if (FILTERS_FIELD.match(currentFieldName)) {
251251
nonKeyedFilters = new ArrayList<>();
252252
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
253253
QueryBuilder filter = context.parseInnerQueryBuilder();

core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static NestedAggregationBuilder parse(String aggregationName, QueryParseC
116116
if (token == XContentParser.Token.FIELD_NAME) {
117117
currentFieldName = parser.currentName();
118118
} else if (token == XContentParser.Token.VALUE_STRING) {
119-
if (context.getParseFieldMatcher().match(currentFieldName, NestedAggregator.PATH_FIELD)) {
119+
if (NestedAggregator.PATH_FIELD.match(currentFieldName)) {
120120
path = parser.text();
121121
} else {
122122
throw new ParsingException(parser.getTokenLocation(),

core/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static SamplerAggregationBuilder parse(String aggregationName, QueryParse
9898
if (token == XContentParser.Token.FIELD_NAME) {
9999
currentFieldName = parser.currentName();
100100
} else if (token == XContentParser.Token.VALUE_NUMBER) {
101-
if (context.getParseFieldMatcher().match(currentFieldName, SamplerAggregator.SHARD_SIZE_FIELD)) {
101+
if (SamplerAggregator.SHARD_SIZE_FIELD.match(currentFieldName)) {
102102
shardSize = parser.intValue();
103103
} else {
104104
throw new ParsingException(parser.getTokenLocation(),

core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static SignificanceHeuristic parse(QueryParseContext context)
157157
if (token.equals(XContentParser.Token.FIELD_NAME)) {
158158
currentFieldName = parser.currentName();
159159
} else {
160-
if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
160+
if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
161161
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
162162
} else {
163163
throw new ElasticsearchParseException("failed to parse [{}] significance heuristic. unknown object [{}]", heuristicName, currentFieldName);

core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,16 @@ public static ScriptedMetricAggregationBuilder parse(String aggregationName, Que
254254
if (token == XContentParser.Token.FIELD_NAME) {
255255
currentFieldName = parser.currentName();
256256
} else if (token == XContentParser.Token.START_OBJECT || token == XContentParser.Token.VALUE_STRING) {
257-
if (context.getParseFieldMatcher().match(currentFieldName, INIT_SCRIPT_FIELD)) {
257+
if (INIT_SCRIPT_FIELD.match(currentFieldName)) {
258258
initScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
259-
} else if (context.getParseFieldMatcher().match(currentFieldName, MAP_SCRIPT_FIELD)) {
259+
} else if (MAP_SCRIPT_FIELD.match(currentFieldName)) {
260260
mapScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
261-
} else if (context.getParseFieldMatcher().match(currentFieldName, COMBINE_SCRIPT_FIELD)) {
261+
} else if (COMBINE_SCRIPT_FIELD.match(currentFieldName)) {
262262
combineScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
263-
} else if (context.getParseFieldMatcher().match(currentFieldName, REDUCE_SCRIPT_FIELD)) {
263+
} else if (REDUCE_SCRIPT_FIELD.match(currentFieldName)) {
264264
reduceScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
265265
} else if (token == XContentParser.Token.START_OBJECT &&
266-
context.getParseFieldMatcher().match(currentFieldName, PARAMS_FIELD)) {
266+
PARAMS_FIELD.match(currentFieldName)) {
267267
params = parser.map();
268268
} else {
269269
throw new ParsingException(parser.getTokenLocation(),

core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,31 +605,31 @@ public static TopHitsAggregationBuilder parse(String aggregationName, QueryParse
605605
if (token == XContentParser.Token.FIELD_NAME) {
606606
currentFieldName = parser.currentName();
607607
} else if (token.isValue()) {
608-
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.FROM_FIELD)) {
608+
if (SearchSourceBuilder.FROM_FIELD.match(currentFieldName)) {
609609
factory.from(parser.intValue());
610-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SIZE_FIELD)) {
610+
} else if (SearchSourceBuilder.SIZE_FIELD.match(currentFieldName)) {
611611
factory.size(parser.intValue());
612-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.VERSION_FIELD)) {
612+
} else if (SearchSourceBuilder.VERSION_FIELD.match(currentFieldName)) {
613613
factory.version(parser.booleanValue());
614-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.EXPLAIN_FIELD)) {
614+
} else if (SearchSourceBuilder.EXPLAIN_FIELD.match(currentFieldName)) {
615615
factory.explain(parser.booleanValue());
616-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.TRACK_SCORES_FIELD)) {
616+
} else if (SearchSourceBuilder.TRACK_SCORES_FIELD.match(currentFieldName)) {
617617
factory.trackScores(parser.booleanValue());
618-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder._SOURCE_FIELD)) {
618+
} else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) {
619619
factory.fetchSource(FetchSourceContext.parse(context.parser()));
620-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.STORED_FIELDS_FIELD)) {
620+
} else if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName)) {
621621
factory.storedFieldsContext =
622622
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), context);
623-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SORT_FIELD)) {
623+
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) {
624624
factory.sort(parser.text());
625625
} else {
626626
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
627627
parser.getTokenLocation());
628628
}
629629
} else if (token == XContentParser.Token.START_OBJECT) {
630-
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder._SOURCE_FIELD)) {
630+
if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) {
631631
factory.fetchSource(FetchSourceContext.parse(context.parser()));
632-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SCRIPT_FIELDS_FIELD)) {
632+
} else if (SearchSourceBuilder.SCRIPT_FIELDS_FIELD.match(currentFieldName)) {
633633
List<ScriptField> scriptFields = new ArrayList<>();
634634
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
635635
String scriptFieldName = parser.currentName();
@@ -641,7 +641,7 @@ public static TopHitsAggregationBuilder parse(String aggregationName, QueryParse
641641
if (token == XContentParser.Token.FIELD_NAME) {
642642
currentFieldName = parser.currentName();
643643
} else if (token.isValue()) {
644-
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SCRIPT_FIELD)) {
644+
if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName)) {
645645
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
646646
} else if (context.getParseFieldMatcher().match(currentFieldName,
647647
SearchSourceBuilder.IGNORE_FAILURE_FIELD)) {
@@ -652,7 +652,7 @@ public static TopHitsAggregationBuilder parse(String aggregationName, QueryParse
652652
parser.getTokenLocation());
653653
}
654654
} else if (token == XContentParser.Token.START_OBJECT) {
655-
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SCRIPT_FIELD)) {
655+
if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName)) {
656656
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
657657
} else {
658658
throw new ParsingException(parser.getTokenLocation(),
@@ -671,9 +671,9 @@ public static TopHitsAggregationBuilder parse(String aggregationName, QueryParse
671671
}
672672
}
673673
factory.scriptFields(scriptFields);
674-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.HIGHLIGHT_FIELD)) {
674+
} else if (SearchSourceBuilder.HIGHLIGHT_FIELD.match(currentFieldName)) {
675675
factory.highlighter(HighlightBuilder.fromXContent(context));
676-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SORT_FIELD)) {
676+
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) {
677677
List<SortBuilder<?>> sorts = SortBuilder.fromXContent(context);
678678
factory.sorts(sorts);
679679
} else {
@@ -682,10 +682,10 @@ public static TopHitsAggregationBuilder parse(String aggregationName, QueryParse
682682
}
683683
} else if (token == XContentParser.Token.START_ARRAY) {
684684

685-
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.STORED_FIELDS_FIELD)) {
685+
if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName)) {
686686
factory.storedFieldsContext =
687687
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), context);
688-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.DOCVALUE_FIELDS_FIELD)) {
688+
} else if (SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.match(currentFieldName)) {
689689
List<String> fieldDataFields = new ArrayList<>();
690690
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
691691
if (token == XContentParser.Token.VALUE_STRING) {
@@ -696,10 +696,10 @@ public static TopHitsAggregationBuilder parse(String aggregationName, QueryParse
696696
}
697697
}
698698
factory.fieldDataFields(fieldDataFields);
699-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SORT_FIELD)) {
699+
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) {
700700
List<SortBuilder<?>> sorts = SortBuilder.fromXContent(context);
701701
factory.sorts(sorts);
702-
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder._SOURCE_FIELD)) {
702+
} else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) {
703703
factory.fetchSource(FetchSourceContext.parse(context.parser()));
704704
} else {
705705
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",

core/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static enum GapPolicy {
6565
public static GapPolicy parse(QueryParseContext context, String text, XContentLocation tokenLocation) {
6666
GapPolicy result = null;
6767
for (GapPolicy policy : values()) {
68-
if (context.getParseFieldMatcher().match(text, policy.parseField)) {
68+
if (policy.parseField.match(text)) {
6969
if (result == null) {
7070
result = policy;
7171
} else {

core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ public final BucketMetricsPipelineAggregationBuilder<?> parse(String pipelineAgg
5858
if (token == XContentParser.Token.FIELD_NAME) {
5959
currentFieldName = parser.currentName();
6060
} else if (token == XContentParser.Token.VALUE_STRING) {
61-
if (context.getParseFieldMatcher().match(currentFieldName, FORMAT)) {
61+
if (FORMAT.match(currentFieldName)) {
6262
format = parser.text();
63-
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
63+
} else if (BUCKETS_PATH.match(currentFieldName)) {
6464
bucketsPaths = new String[] { parser.text() };
65-
} else if (context.getParseFieldMatcher().match(currentFieldName, GAP_POLICY)) {
65+
} else if (GAP_POLICY.match(currentFieldName)) {
6666
gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
6767
} else {
6868
parseToken(pipelineAggregatorName, parser, context, currentFieldName, token, params);
6969
}
7070
} else if (token == XContentParser.Token.START_ARRAY) {
71-
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
71+
if (BUCKETS_PATH.match(currentFieldName)) {
7272
List<String> paths = new ArrayList<>();
7373
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
7474
String path = parser.text();

core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/PercentilesBucketPipelineAggregationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected PercentilesBucketPipelineAggregationBuilder buildFactory(String pipeli
138138
@Override
139139
protected boolean token(XContentParser parser, QueryParseContext context, String field,
140140
XContentParser.Token token, Map<String, Object> params) throws IOException {
141-
if (context.getParseFieldMatcher().match(field, PERCENTS_FIELD) && token == XContentParser.Token.START_ARRAY) {
141+
if (PERCENTS_FIELD.match(field) && token == XContentParser.Token.START_ARRAY) {
142142
DoubleArrayList percents = new DoubleArrayList(10);
143143
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
144144
percents.add(parser.doubleValue());

core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/stats/extended/ExtendedStatsBucketParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected ExtendedStatsBucketPipelineAggregationBuilder buildFactory(String pipe
4646
@Override
4747
protected boolean token(XContentParser parser, QueryParseContext context, String field,
4848
XContentParser.Token token, Map<String, Object> params) throws IOException {
49-
if (context.getParseFieldMatcher().match(field, SIGMA) && token == XContentParser.Token.VALUE_NUMBER) {
49+
if (SIGMA.match(field) && token == XContentParser.Token.VALUE_NUMBER) {
5050
params.put(SIGMA.getPreferredName(), parser.doubleValue());
5151
return true;
5252
}

0 commit comments

Comments
 (0)