Skip to content

Commit

Permalink
Remove some more usages of ParseFieldMatcher in favour of using Parse…
Browse files Browse the repository at this point in the history
…Field directly

Relates to #19552
Relates to #22130
  • Loading branch information
javanna committed Dec 30, 2016
1 parent 45d010e commit 6c54cba
Show file tree
Hide file tree
Showing 47 changed files with 337 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,17 @@ public static BoolQueryBuilder fromXContent(QueryParseContext parseContext) thro
}
}
} else if (token.isValue()) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, DISABLE_COORD_FIELD)) {
if (DISABLE_COORD_FIELD.match(currentFieldName)) {
disableCoord = parser.booleanValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH)) {
} else if (MINIMUM_SHOULD_MATCH.match(currentFieldName)) {
minimumShouldMatch = parser.textOrNull();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_NUMBER_SHOULD_MATCH)) {
} else if (MINIMUM_NUMBER_SHOULD_MATCH.match(currentFieldName)) {
minimumShouldMatch = parser.textOrNull();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, ADJUST_PURE_NEGATIVE)) {
} else if (ADJUST_PURE_NEGATIVE.match(currentFieldName)) {
adjustPureNegative = parser.booleanValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(), "[bool] query does not support [" + currentFieldName + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,21 @@ public static BoostingQueryBuilder fromXContent(QueryParseContext parseContext)
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, POSITIVE_FIELD)) {
if (POSITIVE_FIELD.match(currentFieldName)) {
positiveQuery = parseContext.parseInnerQueryBuilder();
positiveQueryFound = true;
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, NEGATIVE_FIELD)) {
} else if (NEGATIVE_FIELD.match(currentFieldName)) {
negativeQuery = parseContext.parseInnerQueryBuilder();
negativeQueryFound = true;
} else {
throw new ParsingException(parser.getTokenLocation(), "[boosting] query does not support [" + currentFieldName + "]");
}
} else if (token.isValue()) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, NEGATIVE_BOOST_FIELD)) {
if (NEGATIVE_BOOST_FIELD.match(currentFieldName)) {
negativeBoost = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else {
throw new ParsingException(parser.getTokenLocation(), "[boosting] query does not support [" + currentFieldName + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ public static CommonTermsQueryBuilder fromXContent(QueryParseContext parseContex
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH_FIELD)) {
if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) {
String innerFieldName = null;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
innerFieldName = parser.currentName();
} else if (token.isValue()) {
if (parseContext.getParseFieldMatcher().match(innerFieldName, LOW_FREQ_FIELD)) {
if (LOW_FREQ_FIELD.match(innerFieldName)) {
lowFreqMinimumShouldMatch = parser.text();
} else if (parseContext.getParseFieldMatcher().match(innerFieldName, HIGH_FREQ_FIELD)) {
} else if (HIGH_FREQ_FIELD.match(innerFieldName)) {
highFreqMinimumShouldMatch = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(), "[" + CommonTermsQueryBuilder.NAME +
Expand All @@ -316,23 +316,23 @@ public static CommonTermsQueryBuilder fromXContent(QueryParseContext parseContex
"] query does not support [" + currentFieldName + "]");
}
} else if (token.isValue()) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
if (QUERY_FIELD.match(currentFieldName)) {
text = parser.objectText();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, ANALYZER_FIELD)) {
} else if (ANALYZER_FIELD.match(currentFieldName)) {
analyzer = parser.text();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, DISABLE_COORD_FIELD)) {
} else if (DISABLE_COORD_FIELD.match(currentFieldName)) {
disableCoord = parser.booleanValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, HIGH_FREQ_OPERATOR_FIELD)) {
} else if (HIGH_FREQ_OPERATOR_FIELD.match(currentFieldName)) {
highFreqOperator = Operator.fromString(parser.text());
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, LOW_FREQ_OPERATOR_FIELD)) {
} else if (LOW_FREQ_OPERATOR_FIELD.match(currentFieldName)) {
lowFreqOperator = Operator.fromString(parser.text());
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MINIMUM_SHOULD_MATCH_FIELD)) {
} else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) {
lowFreqMinimumShouldMatch = parser.text();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, CUTOFF_FREQUENCY_FIELD)) {
} else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName)) {
cutoffFrequency = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(), "[" + CommonTermsQueryBuilder.NAME +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static ConstantScoreQueryBuilder fromXContent(QueryParseContext parseCont
} else if (parseContext.isDeprecatedSetting(currentFieldName)) {
// skip
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, INNER_QUERY_FIELD)) {
if (INNER_QUERY_FIELD.match(currentFieldName)) {
if (queryFound) {
throw new ParsingException(parser.getTokenLocation(), "[" + ConstantScoreQueryBuilder.NAME + "]"
+ " accepts only one 'filter' element.");
Expand All @@ -113,9 +113,9 @@ public static ConstantScoreQueryBuilder fromXContent(QueryParseContext parseCont
"[constant_score] query does not support [" + currentFieldName + "]");
}
} else if (token.isValue()) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else {
throw new ParsingException(parser.getTokenLocation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ public static DisMaxQueryBuilder fromXContent(QueryParseContext parseContext) th
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
if (QUERIES_FIELD.match(currentFieldName)) {
queriesFound = true;
queries.add(parseContext.parseInnerQueryBuilder());
} else {
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
if (QUERIES_FIELD.match(currentFieldName)) {
queriesFound = true;
while (token != XContentParser.Token.END_ARRAY) {
queries.add(parseContext.parseInnerQueryBuilder());
Expand All @@ -154,11 +154,11 @@ public static DisMaxQueryBuilder fromXContent(QueryParseContext parseContext) th
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
}
} else {
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, TIE_BREAKER_FIELD)) {
} else if (TIE_BREAKER_FIELD.match(currentFieldName)) {
tieBreaker = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public static ExistsQueryBuilder fromXContent(QueryParseContext parseContext) th
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, FIELD_FIELD)) {
if (FIELD_FIELD.match(currentFieldName)) {
fieldPattern = parser.text();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else {
throw new ParsingException(parser.getTokenLocation(), "[" + ExistsQueryBuilder.NAME +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static FieldMaskingSpanQueryBuilder fromXContent(QueryParseContext parseC
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
if (QUERY_FIELD.match(currentFieldName)) {
QueryBuilder query = parseContext.parseInnerQueryBuilder();
if (query instanceof SpanQueryBuilder == false) {
throw new ParsingException(parser.getTokenLocation(), "[field_masking_span] query must be of type span query");
Expand All @@ -126,11 +126,11 @@ public static FieldMaskingSpanQueryBuilder fromXContent(QueryParseContext parseC
+ currentFieldName + "]");
}
} else {
if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, FIELD_FIELD)) {
} else if (FIELD_FIELD.match(currentFieldName)) {
field = parser.text();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,23 @@ public static FuzzyQueryBuilder fromXContent(QueryParseContext parseContext) thr
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else {
if (parseContext.getParseFieldMatcher().match(currentFieldName, TERM_FIELD)) {
if (TERM_FIELD.match(currentFieldName)) {
value = parser.objectBytes();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, VALUE_FIELD)) {
} else if (VALUE_FIELD.match(currentFieldName)) {
value = parser.objectBytes();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
boost = parser.floatValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, Fuzziness.FIELD)) {
} else if (Fuzziness.FIELD.match(currentFieldName)) {
fuzziness = Fuzziness.parse(parser);
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, PREFIX_LENGTH_FIELD)) {
} else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) {
prefixLength = parser.intValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MAX_EXPANSIONS_FIELD)) {
} else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) {
maxExpansions = parser.intValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, TRANSPOSITIONS_FIELD)) {
} else if (TRANSPOSITIONS_FIELD.match(currentFieldName)) {
transpositions = parser.booleanValue();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, REWRITE_FIELD)) {
} else if (REWRITE_FIELD.match(currentFieldName)) {
rewrite = parser.textOrNull();
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
} else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
queryName = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(),
Expand Down
Loading

0 comments on commit 6c54cba

Please sign in to comment.