Skip to content

Commit 4706f10

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 96dcd57 commit 4706f10

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

+337
-337
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
@@ -358,17 +358,17 @@ public static BoolQueryBuilder fromXContent(QueryParseContext parseContext) thro
358358
}
359359
}
360360
} else if (token.isValue()) {
361-
if (parseContext.getParseFieldMatcher().match(currentFieldName, DISABLE_COORD_FIELD)) {
361+
if (DISABLE_COORD_FIELD.match(currentFieldName)) {
362362
disableCoord = parser.booleanValue();
363-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH)) {
363+
} else if (MINIMUM_SHOULD_MATCH.match(currentFieldName)) {
364364
minimumShouldMatch = parser.textOrNull();
365-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
365+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
366366
boost = parser.floatValue();
367-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_NUMBER_SHOULD_MATCH)) {
367+
} else if (MINIMUM_NUMBER_SHOULD_MATCH.match(currentFieldName)) {
368368
minimumShouldMatch = parser.textOrNull();
369-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, ADJUST_PURE_NEGATIVE)) {
369+
} else if (ADJUST_PURE_NEGATIVE.match(currentFieldName)) {
370370
adjustPureNegative = parser.booleanValue();
371-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
371+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
372372
queryName = parser.text();
373373
} else {
374374
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
@@ -153,21 +153,21 @@ public static BoostingQueryBuilder fromXContent(QueryParseContext parseContext)
153153
if (token == XContentParser.Token.FIELD_NAME) {
154154
currentFieldName = parser.currentName();
155155
} else if (token == XContentParser.Token.START_OBJECT) {
156-
if (parseContext.getParseFieldMatcher().match(currentFieldName, POSITIVE_FIELD)) {
156+
if (POSITIVE_FIELD.match(currentFieldName)) {
157157
positiveQuery = parseContext.parseInnerQueryBuilder();
158158
positiveQueryFound = true;
159-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, NEGATIVE_FIELD)) {
159+
} else if (NEGATIVE_FIELD.match(currentFieldName)) {
160160
negativeQuery = parseContext.parseInnerQueryBuilder();
161161
negativeQueryFound = true;
162162
} else {
163163
throw new ParsingException(parser.getTokenLocation(), "[boosting] query does not support [" + currentFieldName + "]");
164164
}
165165
} else if (token.isValue()) {
166-
if (parseContext.getParseFieldMatcher().match(currentFieldName, NEGATIVE_BOOST_FIELD)) {
166+
if (NEGATIVE_BOOST_FIELD.match(currentFieldName)) {
167167
negativeBoost = parser.floatValue();
168-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
168+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
169169
queryName = parser.text();
170-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
170+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
171171
boost = parser.floatValue();
172172
} else {
173173
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
@@ -290,15 +290,15 @@ public static CommonTermsQueryBuilder fromXContent(QueryParseContext parseContex
290290
if (token == XContentParser.Token.FIELD_NAME) {
291291
currentFieldName = parser.currentName();
292292
} else if (token == XContentParser.Token.START_OBJECT) {
293-
if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH_FIELD)) {
293+
if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) {
294294
String innerFieldName = null;
295295
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
296296
if (token == XContentParser.Token.FIELD_NAME) {
297297
innerFieldName = parser.currentName();
298298
} else if (token.isValue()) {
299-
if (parseContext.getParseFieldMatcher().match(innerFieldName, LOW_FREQ_FIELD)) {
299+
if (LOW_FREQ_FIELD.match(innerFieldName)) {
300300
lowFreqMinimumShouldMatch = parser.text();
301-
} else if (parseContext.getParseFieldMatcher().match(innerFieldName, HIGH_FREQ_FIELD)) {
301+
} else if (HIGH_FREQ_FIELD.match(innerFieldName)) {
302302
highFreqMinimumShouldMatch = parser.text();
303303
} else {
304304
throw new ParsingException(parser.getTokenLocation(), "[" + CommonTermsQueryBuilder.NAME +
@@ -316,23 +316,23 @@ public static CommonTermsQueryBuilder fromXContent(QueryParseContext parseContex
316316
"] query does not support [" + currentFieldName + "]");
317317
}
318318
} else if (token.isValue()) {
319-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
319+
if (QUERY_FIELD.match(currentFieldName)) {
320320
text = parser.objectText();
321-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, ANALYZER_FIELD)) {
321+
} else if (ANALYZER_FIELD.match(currentFieldName)) {
322322
analyzer = parser.text();
323-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, DISABLE_COORD_FIELD)) {
323+
} else if (DISABLE_COORD_FIELD.match(currentFieldName)) {
324324
disableCoord = parser.booleanValue();
325-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
325+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
326326
boost = parser.floatValue();
327-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, HIGH_FREQ_OPERATOR_FIELD)) {
327+
} else if (HIGH_FREQ_OPERATOR_FIELD.match(currentFieldName)) {
328328
highFreqOperator = Operator.fromString(parser.text());
329-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, LOW_FREQ_OPERATOR_FIELD)) {
329+
} else if (LOW_FREQ_OPERATOR_FIELD.match(currentFieldName)) {
330330
lowFreqOperator = Operator.fromString(parser.text());
331-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH_FIELD)) {
331+
} else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) {
332332
lowFreqMinimumShouldMatch = parser.text();
333-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, CUTOFF_FREQUENCY_FIELD)) {
333+
} else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName)) {
334334
cutoffFrequency = parser.floatValue();
335-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
335+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
336336
queryName = parser.text();
337337
} else {
338338
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
@@ -101,7 +101,7 @@ public static ConstantScoreQueryBuilder fromXContent(QueryParseContext parseCont
101101
} else if (parseContext.isDeprecatedSetting(currentFieldName)) {
102102
// skip
103103
} else if (token == XContentParser.Token.START_OBJECT) {
104-
if (parseContext.getParseFieldMatcher().match(currentFieldName, INNER_QUERY_FIELD)) {
104+
if (INNER_QUERY_FIELD.match(currentFieldName)) {
105105
if (queryFound) {
106106
throw new ParsingException(parser.getTokenLocation(), "[" + ConstantScoreQueryBuilder.NAME + "]"
107107
+ " accepts only one 'filter' element.");
@@ -113,9 +113,9 @@ public static ConstantScoreQueryBuilder fromXContent(QueryParseContext parseCont
113113
"[constant_score] query does not support [" + currentFieldName + "]");
114114
}
115115
} else if (token.isValue()) {
116-
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
116+
if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
117117
queryName = parser.text();
118-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
118+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
119119
boost = parser.floatValue();
120120
} else {
121121
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
@@ -137,14 +137,14 @@ public static DisMaxQueryBuilder fromXContent(QueryParseContext parseContext) th
137137
if (token == XContentParser.Token.FIELD_NAME) {
138138
currentFieldName = parser.currentName();
139139
} else if (token == XContentParser.Token.START_OBJECT) {
140-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
140+
if (QUERIES_FIELD.match(currentFieldName)) {
141141
queriesFound = true;
142142
queries.add(parseContext.parseInnerQueryBuilder());
143143
} else {
144144
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
145145
}
146146
} else if (token == XContentParser.Token.START_ARRAY) {
147-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
147+
if (QUERIES_FIELD.match(currentFieldName)) {
148148
queriesFound = true;
149149
while (token != XContentParser.Token.END_ARRAY) {
150150
queries.add(parseContext.parseInnerQueryBuilder());
@@ -154,11 +154,11 @@ public static DisMaxQueryBuilder fromXContent(QueryParseContext parseContext) th
154154
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
155155
}
156156
} else {
157-
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
157+
if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
158158
boost = parser.floatValue();
159-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, TIE_BREAKER_FIELD)) {
159+
} else if (TIE_BREAKER_FIELD.match(currentFieldName)) {
160160
tieBreaker = parser.floatValue();
161-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
161+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
162162
queryName = parser.text();
163163
} else {
164164
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
@@ -96,11 +96,11 @@ public static ExistsQueryBuilder fromXContent(QueryParseContext parseContext) th
9696
if (token == XContentParser.Token.FIELD_NAME) {
9797
currentFieldName = parser.currentName();
9898
} else if (token.isValue()) {
99-
if (parseContext.getParseFieldMatcher().match(currentFieldName, FIELD_FIELD)) {
99+
if (FIELD_FIELD.match(currentFieldName)) {
100100
fieldPattern = parser.text();
101-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
101+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
102102
queryName = parser.text();
103-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
103+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
104104
boost = parser.floatValue();
105105
} else {
106106
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
@@ -115,7 +115,7 @@ public static FieldMaskingSpanQueryBuilder fromXContent(QueryParseContext parseC
115115
if (token == XContentParser.Token.FIELD_NAME) {
116116
currentFieldName = parser.currentName();
117117
} else if (token == XContentParser.Token.START_OBJECT) {
118-
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
118+
if (QUERY_FIELD.match(currentFieldName)) {
119119
QueryBuilder query = parseContext.parseInnerQueryBuilder();
120120
if (query instanceof SpanQueryBuilder == false) {
121121
throw new ParsingException(parser.getTokenLocation(), "[field_masking_span] query must be of type span query");
@@ -126,11 +126,11 @@ public static FieldMaskingSpanQueryBuilder fromXContent(QueryParseContext parseC
126126
+ currentFieldName + "]");
127127
}
128128
} else {
129-
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
129+
if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
130130
boost = parser.floatValue();
131-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, FIELD_FIELD)) {
131+
} else if (FIELD_FIELD.match(currentFieldName)) {
132132
field = parser.text();
133-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
133+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
134134
queryName = parser.text();
135135
} else {
136136
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
@@ -276,23 +276,23 @@ public static FuzzyQueryBuilder fromXContent(QueryParseContext parseContext) thr
276276
if (token == XContentParser.Token.FIELD_NAME) {
277277
currentFieldName = parser.currentName();
278278
} else {
279-
if (parseContext.getParseFieldMatcher().match(currentFieldName, TERM_FIELD)) {
279+
if (TERM_FIELD.match(currentFieldName)) {
280280
value = parser.objectBytes();
281-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, VALUE_FIELD)) {
281+
} else if (VALUE_FIELD.match(currentFieldName)) {
282282
value = parser.objectBytes();
283-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
283+
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
284284
boost = parser.floatValue();
285-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, Fuzziness.FIELD)) {
285+
} else if (Fuzziness.FIELD.match(currentFieldName)) {
286286
fuzziness = Fuzziness.parse(parser);
287-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, PREFIX_LENGTH_FIELD)) {
287+
} else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) {
288288
prefixLength = parser.intValue();
289-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MAX_EXPANSIONS_FIELD)) {
289+
} else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) {
290290
maxExpansions = parser.intValue();
291-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, TRANSPOSITIONS_FIELD)) {
291+
} else if (TRANSPOSITIONS_FIELD.match(currentFieldName)) {
292292
transpositions = parser.booleanValue();
293-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, REWRITE_FIELD)) {
293+
} else if (REWRITE_FIELD.match(currentFieldName)) {
294294
rewrite = parser.textOrNull();
295-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
295+
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
296296
queryName = parser.text();
297297
} else {
298298
throw new ParsingException(parser.getTokenLocation(),

0 commit comments

Comments
 (0)