Skip to content

Commit 1295bde

Browse files
committed
Remove some more usages of ParseFieldMatcher in favour of using ParseField directly
Relates to elastic#19552 Relates to elastic#22130
1 parent b1f4a88 commit 1295bde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+339
-339
lines changed

core/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,17 @@ public static Optional<BoolQueryBuilder> fromXContent(QueryParseContext parseCon
359359
}
360360
}
361361
} else if (token.isValue()) {
362-
if (parseContext.getParseFieldMatcher().match(currentFieldName, DISABLE_COORD_FIELD)) {
362+
if (DISABLE_COORD_FIELD.match(currentFieldName)) {
363363
disableCoord = parser.booleanValue();
364-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH)) {
364+
} else if (MINIMUM_SHOULD_MATCH.match(currentFieldName)) {
365365
minimumShouldMatch = parser.textOrNull();
366-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
366+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
367367
boost = parser.floatValue();
368-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_NUMBER_SHOULD_MATCH)) {
368+
} else if (MINIMUM_NUMBER_SHOULD_MATCH.match(currentFieldName)) {
369369
minimumShouldMatch = parser.textOrNull();
370-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, ADJUST_PURE_NEGATIVE)) {
370+
} else if (ADJUST_PURE_NEGATIVE.match(currentFieldName)) {
371371
adjustPureNegative = parser.booleanValue();
372-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
372+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
373373
queryName = parser.text();
374374
} else {
375375
throw new ParsingException(parser.getTokenLocation(), "[bool] query does not support [" + currentFieldName + "]");

core/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,21 @@ public static Optional<BoostingQueryBuilder> fromXContent(QueryParseContext pars
154154
if (token == XContentParser.Token.FIELD_NAME) {
155155
currentFieldName = parser.currentName();
156156
} else if (token == XContentParser.Token.START_OBJECT) {
157-
if (parseContext.getParseFieldMatcher().match(currentFieldName, POSITIVE_FIELD)) {
157+
if (POSITIVE_FIELD.match(currentFieldName)) {
158158
positiveQuery = parseContext.parseInnerQueryBuilder();
159159
positiveQueryFound = true;
160-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, NEGATIVE_FIELD)) {
160+
} else if (NEGATIVE_FIELD.match(currentFieldName)) {
161161
negativeQuery = parseContext.parseInnerQueryBuilder();
162162
negativeQueryFound = true;
163163
} else {
164164
throw new ParsingException(parser.getTokenLocation(), "[boosting] query does not support [" + currentFieldName + "]");
165165
}
166166
} else if (token.isValue()) {
167-
if (parseContext.getParseFieldMatcher().match(currentFieldName, NEGATIVE_BOOST_FIELD)) {
167+
if (NEGATIVE_BOOST_FIELD.match(currentFieldName)) {
168168
negativeBoost = parser.floatValue();
169-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
169+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
170170
queryName = parser.text();
171-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
171+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
172172
boost = parser.floatValue();
173173
} else {
174174
throw new ParsingException(parser.getTokenLocation(), "[boosting] query does not support [" + currentFieldName + "]");

core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ public static Optional<CommonTermsQueryBuilder> fromXContent(QueryParseContext p
291291
if (token == XContentParser.Token.FIELD_NAME) {
292292
currentFieldName = parser.currentName();
293293
} else if (token == XContentParser.Token.START_OBJECT) {
294-
if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH_FIELD)) {
294+
if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) {
295295
String innerFieldName = null;
296296
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
297297
if (token == XContentParser.Token.FIELD_NAME) {
298298
innerFieldName = parser.currentName();
299299
} else if (token.isValue()) {
300-
if (parseContext.getParseFieldMatcher().match(innerFieldName, LOW_FREQ_FIELD)) {
300+
if (LOW_FREQ_FIELD.match(innerFieldName)) {
301301
lowFreqMinimumShouldMatch = parser.text();
302-
} else if (parseContext.getParseFieldMatcher().match(innerFieldName, HIGH_FREQ_FIELD)) {
302+
} else if (HIGH_FREQ_FIELD.match(innerFieldName)) {
303303
highFreqMinimumShouldMatch = parser.text();
304304
} else {
305305
throw new ParsingException(parser.getTokenLocation(), "[" + CommonTermsQueryBuilder.NAME +
@@ -317,23 +317,23 @@ public static Optional<CommonTermsQueryBuilder> fromXContent(QueryParseContext p
317317
"] query does not support [" + currentFieldName + "]");
318318
}
319319
} else if (token.isValue()) {
320-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
320+
if (QUERY_FIELD.match(currentFieldName)) {
321321
text = parser.objectText();
322-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, ANALYZER_FIELD)) {
322+
} else if (ANALYZER_FIELD.match(currentFieldName)) {
323323
analyzer = parser.text();
324-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, DISABLE_COORD_FIELD)) {
324+
} else if (DISABLE_COORD_FIELD.match(currentFieldName)) {
325325
disableCoord = parser.booleanValue();
326-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
326+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
327327
boost = parser.floatValue();
328-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, HIGH_FREQ_OPERATOR_FIELD)) {
328+
} else if (HIGH_FREQ_OPERATOR_FIELD.match(currentFieldName)) {
329329
highFreqOperator = Operator.fromString(parser.text());
330-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, LOW_FREQ_OPERATOR_FIELD)) {
330+
} else if (LOW_FREQ_OPERATOR_FIELD.match(currentFieldName)) {
331331
lowFreqOperator = Operator.fromString(parser.text());
332-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH_FIELD)) {
332+
} else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) {
333333
lowFreqMinimumShouldMatch = parser.text();
334-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, CUTOFF_FREQUENCY_FIELD)) {
334+
} else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName)) {
335335
cutoffFrequency = parser.floatValue();
336-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
336+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
337337
queryName = parser.text();
338338
} else {
339339
throw new ParsingException(parser.getTokenLocation(), "[" + CommonTermsQueryBuilder.NAME +

core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static Optional<ConstantScoreQueryBuilder> fromXContent(QueryParseContext
102102
} else if (parseContext.isDeprecatedSetting(currentFieldName)) {
103103
// skip
104104
} else if (token == XContentParser.Token.START_OBJECT) {
105-
if (parseContext.getParseFieldMatcher().match(currentFieldName, INNER_QUERY_FIELD)) {
105+
if (INNER_QUERY_FIELD.match(currentFieldName)) {
106106
if (queryFound) {
107107
throw new ParsingException(parser.getTokenLocation(), "[" + ConstantScoreQueryBuilder.NAME + "]"
108108
+ " accepts only one 'filter' element.");
@@ -114,9 +114,9 @@ public static Optional<ConstantScoreQueryBuilder> fromXContent(QueryParseContext
114114
"[constant_score] query does not support [" + currentFieldName + "]");
115115
}
116116
} else if (token.isValue()) {
117-
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
117+
if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
118118
queryName = parser.text();
119-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
119+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
120120
boost = parser.floatValue();
121121
} else {
122122
throw new ParsingException(parser.getTokenLocation(),

core/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ public static Optional<DisMaxQueryBuilder> fromXContent(QueryParseContext parseC
138138
if (token == XContentParser.Token.FIELD_NAME) {
139139
currentFieldName = parser.currentName();
140140
} else if (token == XContentParser.Token.START_OBJECT) {
141-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
141+
if (QUERIES_FIELD.match(currentFieldName)) {
142142
queriesFound = true;
143143
parseContext.parseInnerQueryBuilder().ifPresent(queries::add);
144144
} else {
145145
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
146146
}
147147
} else if (token == XContentParser.Token.START_ARRAY) {
148-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
148+
if (QUERIES_FIELD.match(currentFieldName)) {
149149
queriesFound = true;
150150
while (token != XContentParser.Token.END_ARRAY) {
151151
parseContext.parseInnerQueryBuilder().ifPresent(queries::add);
@@ -155,11 +155,11 @@ public static Optional<DisMaxQueryBuilder> fromXContent(QueryParseContext parseC
155155
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
156156
}
157157
} else {
158-
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
158+
if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
159159
boost = parser.floatValue();
160-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, TIE_BREAKER_FIELD)) {
160+
} else if (TIE_BREAKER_FIELD.match(currentFieldName)) {
161161
tieBreaker = parser.floatValue();
162-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
162+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
163163
queryName = parser.text();
164164
} else {
165165
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");

core/src/main/java/org/elasticsearch/index/query/ExistsQueryBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ public static Optional<ExistsQueryBuilder> fromXContent(QueryParseContext parseC
9797
if (token == XContentParser.Token.FIELD_NAME) {
9898
currentFieldName = parser.currentName();
9999
} else if (token.isValue()) {
100-
if (parseContext.getParseFieldMatcher().match(currentFieldName, FIELD_FIELD)) {
100+
if (FIELD_FIELD.match(currentFieldName)) {
101101
fieldPattern = parser.text();
102-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
102+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
103103
queryName = parser.text();
104-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
104+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
105105
boost = parser.floatValue();
106106
} else {
107107
throw new ParsingException(parser.getTokenLocation(), "[" + ExistsQueryBuilder.NAME +

core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static Optional<FieldMaskingSpanQueryBuilder> fromXContent(QueryParseCont
116116
if (token == XContentParser.Token.FIELD_NAME) {
117117
currentFieldName = parser.currentName();
118118
} else if (token == XContentParser.Token.START_OBJECT) {
119-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
119+
if (QUERY_FIELD.match(currentFieldName)) {
120120
Optional<QueryBuilder> query = parseContext.parseInnerQueryBuilder();
121121
if (query.isPresent() == false || query.get() instanceof SpanQueryBuilder == false) {
122122
throw new ParsingException(parser.getTokenLocation(), "[field_masking_span] query must be of type span query");
@@ -127,11 +127,11 @@ public static Optional<FieldMaskingSpanQueryBuilder> fromXContent(QueryParseCont
127127
+ currentFieldName + "]");
128128
}
129129
} else {
130-
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
130+
if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
131131
boost = parser.floatValue();
132-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, FIELD_FIELD)) {
132+
} else if (FIELD_FIELD.match(currentFieldName)) {
133133
field = parser.text();
134-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
134+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
135135
queryName = parser.text();
136136
} else {
137137
throw new ParsingException(parser.getTokenLocation(),

core/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,23 +284,23 @@ public static Optional<FuzzyQueryBuilder> fromXContent(QueryParseContext parseCo
284284
if (token == XContentParser.Token.FIELD_NAME) {
285285
currentFieldName = parser.currentName();
286286
} else {
287-
if (parseContext.getParseFieldMatcher().match(currentFieldName, TERM_FIELD)) {
287+
if (TERM_FIELD.match(currentFieldName)) {
288288
value = parser.objectBytes();
289-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, VALUE_FIELD)) {
289+
} else if (VALUE_FIELD.match(currentFieldName)) {
290290
value = parser.objectBytes();
291-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
291+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
292292
boost = parser.floatValue();
293-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, Fuzziness.FIELD)) {
293+
} else if (Fuzziness.FIELD.match(currentFieldName)) {
294294
fuzziness = Fuzziness.parse(parser);
295-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, PREFIX_LENGTH_FIELD)) {
295+
} else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) {
296296
prefixLength = parser.intValue();
297-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MAX_EXPANSIONS_FIELD)) {
297+
} else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) {
298298
maxExpansions = parser.intValue();
299-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, TRANSPOSITIONS_FIELD)) {
299+
} else if (TRANSPOSITIONS_FIELD.match(currentFieldName)) {
300300
transpositions = parser.booleanValue();
301-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, REWRITE_FIELD)) {
301+
} else if (REWRITE_FIELD.match(currentFieldName)) {
302302
rewrite = parser.textOrNull();
303-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
303+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
304304
queryName = parser.text();
305305
} else {
306306
throw new ParsingException(parser.getTokenLocation(),

0 commit comments

Comments
 (0)