Remove some usages of ParseFieldMatcher in favour of using ParseField directly

Relates to #19552
Relates to #22130
This commit is contained in:
javanna 2016-12-30 15:15:00 +01:00 committed by Luca Cavanna
parent eaefb5f99b
commit 45d010e874
19 changed files with 113 additions and 113 deletions

View File

@ -112,7 +112,7 @@ public final class DecayFunctionParser<DFB extends DecayFunctionBuilder<DFB>> im
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.copyCurrentStructure(parser);
functionBytes = builder.bytes();
} else if (context.getParseFieldMatcher().match(currentFieldName, MULTI_VALUE_MODE)) {
} else if (MULTI_VALUE_MODE.match(currentFieldName)) {
multiValueMode = MultiValueMode.fromString(parser.text());
} else {
throw new ParsingException(parser.getTokenLocation(), "malformed score function score parameters.");

View File

@ -217,21 +217,21 @@ public class FiltersAggregationBuilder extends AbstractAggregationBuilder<Filter
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
if (context.getParseFieldMatcher().match(currentFieldName, OTHER_BUCKET_FIELD)) {
if (OTHER_BUCKET_FIELD.match(currentFieldName)) {
otherBucket = parser.booleanValue();
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, OTHER_BUCKET_KEY_FIELD)) {
if (OTHER_BUCKET_KEY_FIELD.match(currentFieldName)) {
otherBucketKey = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, FILTERS_FIELD)) {
if (FILTERS_FIELD.match(currentFieldName)) {
keyedFilters = new ArrayList<>();
String key = null;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
@ -247,7 +247,7 @@ public class FiltersAggregationBuilder extends AbstractAggregationBuilder<Filter
"Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, FILTERS_FIELD)) {
if (FILTERS_FIELD.match(currentFieldName)) {
nonKeyedFilters = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
QueryBuilder filter = context.parseInnerQueryBuilder();

View File

@ -116,7 +116,7 @@ public class NestedAggregationBuilder extends AbstractAggregationBuilder<NestedA
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, NestedAggregator.PATH_FIELD)) {
if (NestedAggregator.PATH_FIELD.match(currentFieldName)) {
path = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(),

View File

@ -98,7 +98,7 @@ public class SamplerAggregationBuilder extends AbstractAggregationBuilder<Sample
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_NUMBER) {
if (context.getParseFieldMatcher().match(currentFieldName, SamplerAggregator.SHARD_SIZE_FIELD)) {
if (SamplerAggregator.SHARD_SIZE_FIELD.match(currentFieldName)) {
shardSize = parser.intValue();
} else {
throw new ParsingException(parser.getTokenLocation(),

View File

@ -157,7 +157,7 @@ public class ScriptHeuristic extends SignificanceHeuristic {
if (token.equals(XContentParser.Token.FIELD_NAME)) {
currentFieldName = parser.currentName();
} else {
if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else {
throw new ElasticsearchParseException("failed to parse [{}] significance heuristic. unknown object [{}]", heuristicName, currentFieldName);

View File

@ -254,16 +254,16 @@ public class ScriptedMetricAggregationBuilder extends AbstractAggregationBuilder
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT || token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, INIT_SCRIPT_FIELD)) {
if (INIT_SCRIPT_FIELD.match(currentFieldName)) {
initScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (context.getParseFieldMatcher().match(currentFieldName, MAP_SCRIPT_FIELD)) {
} else if (MAP_SCRIPT_FIELD.match(currentFieldName)) {
mapScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (context.getParseFieldMatcher().match(currentFieldName, COMBINE_SCRIPT_FIELD)) {
} else if (COMBINE_SCRIPT_FIELD.match(currentFieldName)) {
combineScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (context.getParseFieldMatcher().match(currentFieldName, REDUCE_SCRIPT_FIELD)) {
} else if (REDUCE_SCRIPT_FIELD.match(currentFieldName)) {
reduceScript = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (token == XContentParser.Token.START_OBJECT &&
context.getParseFieldMatcher().match(currentFieldName, PARAMS_FIELD)) {
PARAMS_FIELD.match(currentFieldName)) {
params = parser.map();
} else {
throw new ParsingException(parser.getTokenLocation(),

View File

@ -605,31 +605,31 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.FROM_FIELD)) {
if (SearchSourceBuilder.FROM_FIELD.match(currentFieldName)) {
factory.from(parser.intValue());
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SIZE_FIELD)) {
} else if (SearchSourceBuilder.SIZE_FIELD.match(currentFieldName)) {
factory.size(parser.intValue());
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.VERSION_FIELD)) {
} else if (SearchSourceBuilder.VERSION_FIELD.match(currentFieldName)) {
factory.version(parser.booleanValue());
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.EXPLAIN_FIELD)) {
} else if (SearchSourceBuilder.EXPLAIN_FIELD.match(currentFieldName)) {
factory.explain(parser.booleanValue());
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.TRACK_SCORES_FIELD)) {
} else if (SearchSourceBuilder.TRACK_SCORES_FIELD.match(currentFieldName)) {
factory.trackScores(parser.booleanValue());
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder._SOURCE_FIELD)) {
} else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) {
factory.fetchSource(FetchSourceContext.parse(context.parser()));
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.STORED_FIELDS_FIELD)) {
} else if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName)) {
factory.storedFieldsContext =
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), context);
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SORT_FIELD)) {
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) {
factory.sort(parser.text());
} else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
parser.getTokenLocation());
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder._SOURCE_FIELD)) {
if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) {
factory.fetchSource(FetchSourceContext.parse(context.parser()));
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SCRIPT_FIELDS_FIELD)) {
} else if (SearchSourceBuilder.SCRIPT_FIELDS_FIELD.match(currentFieldName)) {
List<ScriptField> scriptFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
String scriptFieldName = parser.currentName();
@ -641,7 +641,7 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SCRIPT_FIELD)) {
if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (context.getParseFieldMatcher().match(currentFieldName,
SearchSourceBuilder.IGNORE_FAILURE_FIELD)) {
@ -652,7 +652,7 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
parser.getTokenLocation());
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SCRIPT_FIELD)) {
if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else {
throw new ParsingException(parser.getTokenLocation(),
@ -671,9 +671,9 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
}
}
factory.scriptFields(scriptFields);
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.HIGHLIGHT_FIELD)) {
} else if (SearchSourceBuilder.HIGHLIGHT_FIELD.match(currentFieldName)) {
factory.highlighter(HighlightBuilder.fromXContent(context));
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SORT_FIELD)) {
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) {
List<SortBuilder<?>> sorts = SortBuilder.fromXContent(context);
factory.sorts(sorts);
} else {
@ -682,10 +682,10 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.STORED_FIELDS_FIELD)) {
if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName)) {
factory.storedFieldsContext =
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), context);
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.DOCVALUE_FIELDS_FIELD)) {
} else if (SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.match(currentFieldName)) {
List<String> fieldDataFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) {
@ -696,10 +696,10 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
}
}
factory.fieldDataFields(fieldDataFields);
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder.SORT_FIELD)) {
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) {
List<SortBuilder<?>> sorts = SortBuilder.fromXContent(context);
factory.sorts(sorts);
} else if (context.getParseFieldMatcher().match(currentFieldName, SearchSourceBuilder._SOURCE_FIELD)) {
} else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) {
factory.fetchSource(FetchSourceContext.parse(context.parser()));
} else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",

View File

@ -65,7 +65,7 @@ public class BucketHelpers {
public static GapPolicy parse(QueryParseContext context, String text, XContentLocation tokenLocation) {
GapPolicy result = null;
for (GapPolicy policy : values()) {
if (context.getParseFieldMatcher().match(text, policy.parseField)) {
if (policy.parseField.match(text)) {
if (result == null) {
result = policy;
} else {

View File

@ -58,17 +58,17 @@ public abstract class BucketMetricsParser implements PipelineAggregator.Parser {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, FORMAT)) {
if (FORMAT.match(currentFieldName)) {
format = parser.text();
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
} else if (BUCKETS_PATH.match(currentFieldName)) {
bucketsPaths = new String[] { parser.text() };
} else if (context.getParseFieldMatcher().match(currentFieldName, GAP_POLICY)) {
} else if (GAP_POLICY.match(currentFieldName)) {
gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
} else {
parseToken(pipelineAggregatorName, parser, context, currentFieldName, token, params);
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
if (BUCKETS_PATH.match(currentFieldName)) {
List<String> paths = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
String path = parser.text();

View File

@ -138,7 +138,7 @@ public class PercentilesBucketPipelineAggregationBuilder
@Override
protected boolean token(XContentParser parser, QueryParseContext context, String field,
XContentParser.Token token, Map<String, Object> params) throws IOException {
if (context.getParseFieldMatcher().match(field, PERCENTS_FIELD) && token == XContentParser.Token.START_ARRAY) {
if (PERCENTS_FIELD.match(field) && token == XContentParser.Token.START_ARRAY) {
DoubleArrayList percents = new DoubleArrayList(10);
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
percents.add(parser.doubleValue());

View File

@ -46,7 +46,7 @@ public class ExtendedStatsBucketParser extends BucketMetricsParser {
@Override
protected boolean token(XContentParser parser, QueryParseContext context, String field,
XContentParser.Token token, Map<String, Object> params) throws IOException {
if (context.getParseFieldMatcher().match(field, SIGMA) && token == XContentParser.Token.VALUE_NUMBER) {
if (SIGMA.match(field) && token == XContentParser.Token.VALUE_NUMBER) {
params.put(SIGMA.getPreferredName(), parser.doubleValue());
return true;
}

View File

@ -170,21 +170,21 @@ public class BucketScriptPipelineAggregationBuilder extends AbstractPipelineAggr
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, FORMAT)) {
if (FORMAT.match(currentFieldName)) {
format = parser.text();
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
} else if (BUCKETS_PATH.match(currentFieldName)) {
bucketsPathsMap = new HashMap<>();
bucketsPathsMap.put("_value", parser.text());
} else if (context.getParseFieldMatcher().match(currentFieldName, GAP_POLICY)) {
} else if (GAP_POLICY.match(currentFieldName)) {
gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
} else if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
} else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
if (BUCKETS_PATH.match(currentFieldName)) {
List<String> paths = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
String path = parser.text();
@ -199,9 +199,9 @@ public class BucketScriptPipelineAggregationBuilder extends AbstractPipelineAggr
"Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
} else if (BUCKETS_PATH.match(currentFieldName)) {
Map<String, Object> map = parser.map();
bucketsPathsMap = new HashMap<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {

View File

@ -135,19 +135,19 @@ public class BucketSelectorPipelineAggregationBuilder extends AbstractPipelineAg
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
if (BUCKETS_PATH.match(currentFieldName)) {
bucketsPathsMap = new HashMap<>();
bucketsPathsMap.put("_value", parser.text());
} else if (context.getParseFieldMatcher().match(currentFieldName, GAP_POLICY)) {
} else if (GAP_POLICY.match(currentFieldName)) {
gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
} else if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
} else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
if (BUCKETS_PATH.match(currentFieldName)) {
List<String> paths = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
String path = parser.text();
@ -162,9 +162,9 @@ public class BucketSelectorPipelineAggregationBuilder extends AbstractPipelineAg
"Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
} else if (BUCKETS_PATH.match(currentFieldName)) {
Map<String, Object> map = parser.map();
bucketsPathsMap = new HashMap<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {

View File

@ -141,16 +141,16 @@ public class CumulativeSumPipelineAggregationBuilder extends AbstractPipelineAgg
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, FORMAT)) {
if (FORMAT.match(currentFieldName)) {
format = parser.text();
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
} else if (BUCKETS_PATH.match(currentFieldName)) {
bucketsPaths = new String[] { parser.text() };
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
if (BUCKETS_PATH.match(currentFieldName)) {
List<String> paths = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
String path = parser.text();

View File

@ -207,20 +207,20 @@ public class DerivativePipelineAggregationBuilder extends AbstractPipelineAggreg
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, FORMAT_FIELD)) {
if (FORMAT_FIELD.match(currentFieldName)) {
format = parser.text();
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH_FIELD)) {
} else if (BUCKETS_PATH_FIELD.match(currentFieldName)) {
bucketsPaths = new String[] { parser.text() };
} else if (context.getParseFieldMatcher().match(currentFieldName, GAP_POLICY_FIELD)) {
} else if (GAP_POLICY_FIELD.match(currentFieldName)) {
gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
} else if (context.getParseFieldMatcher().match(currentFieldName, UNIT_FIELD)) {
} else if (UNIT_FIELD.match(currentFieldName)) {
units = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH_FIELD)) {
if (BUCKETS_PATH_FIELD.match(currentFieldName)) {
List<String> paths = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
String path = parser.text();

View File

@ -322,13 +322,13 @@ public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregatio
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_NUMBER) {
if (context.getParseFieldMatcher().match(currentFieldName, WINDOW)) {
if (WINDOW.match(currentFieldName)) {
window = parser.intValue();
if (window <= 0) {
throw new ParsingException(parser.getTokenLocation(), "[" + currentFieldName + "] value must be a positive, "
+ "non-zero integer. Value supplied was [" + predict + "] in [" + pipelineAggregatorName + "].");
}
} else if (context.getParseFieldMatcher().match(currentFieldName, PREDICT)) {
} else if (PREDICT.match(currentFieldName)) {
predict = parser.intValue();
if (predict <= 0) {
throw new ParsingException(parser.getTokenLocation(), "[" + currentFieldName + "] value must be a positive integer."
@ -339,20 +339,20 @@ public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregatio
"Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, FORMAT)) {
if (FORMAT.match(currentFieldName)) {
format = parser.text();
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
} else if (BUCKETS_PATH.match(currentFieldName)) {
bucketsPaths = new String[] { parser.text() };
} else if (context.getParseFieldMatcher().match(currentFieldName, GAP_POLICY)) {
} else if (GAP_POLICY.match(currentFieldName)) {
gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
} else if (context.getParseFieldMatcher().match(currentFieldName, MODEL)) {
} else if (MODEL.match(currentFieldName)) {
model = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
if (BUCKETS_PATH.match(currentFieldName)) {
List<String> paths = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
String path = parser.text();
@ -364,14 +364,14 @@ public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregatio
"Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, SETTINGS)) {
if (SETTINGS.match(currentFieldName)) {
settings = parser.map();
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
if (context.getParseFieldMatcher().match(currentFieldName, MINIMIZE)) {
if (MINIMIZE.match(currentFieldName)) {
minimize = parser.booleanValue();
} else {
throw new ParsingException(parser.getTokenLocation(),

View File

@ -162,18 +162,18 @@ public class SerialDiffPipelineAggregationBuilder extends AbstractPipelineAggreg
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
if (context.getParseFieldMatcher().match(currentFieldName, FORMAT)) {
if (FORMAT.match(currentFieldName)) {
format = parser.text();
} else if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
} else if (BUCKETS_PATH.match(currentFieldName)) {
bucketsPaths = new String[] { parser.text() };
} else if (context.getParseFieldMatcher().match(currentFieldName, GAP_POLICY)) {
} else if (GAP_POLICY.match(currentFieldName)) {
gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
} else {
throw new ParsingException(parser.getTokenLocation(),
"Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.VALUE_NUMBER) {
if (context.getParseFieldMatcher().match(currentFieldName, LAG)) {
if (LAG.match(currentFieldName)) {
lag = parser.intValue(true);
if (lag <= 0) {
throw new ParsingException(parser.getTokenLocation(),
@ -186,7 +186,7 @@ public class SerialDiffPipelineAggregationBuilder extends AbstractPipelineAggreg
"Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
if (BUCKETS_PATH.match(currentFieldName)) {
List<String> paths = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
String path = parser.text();

View File

@ -931,32 +931,32 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if (context.getParseFieldMatcher().match(currentFieldName, FROM_FIELD)) {
if (FROM_FIELD.match(currentFieldName)) {
from = parser.intValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, SIZE_FIELD)) {
} else if (SIZE_FIELD.match(currentFieldName)) {
size = parser.intValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, TIMEOUT_FIELD)) {
} else if (TIMEOUT_FIELD.match(currentFieldName)) {
timeout = TimeValue.parseTimeValue(parser.text(), null, TIMEOUT_FIELD.getPreferredName());
} else if (context.getParseFieldMatcher().match(currentFieldName, TERMINATE_AFTER_FIELD)) {
} else if (TERMINATE_AFTER_FIELD.match(currentFieldName)) {
terminateAfter = parser.intValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, MIN_SCORE_FIELD)) {
} else if (MIN_SCORE_FIELD.match(currentFieldName)) {
minScore = parser.floatValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, VERSION_FIELD)) {
} else if (VERSION_FIELD.match(currentFieldName)) {
version = parser.booleanValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, EXPLAIN_FIELD)) {
} else if (EXPLAIN_FIELD.match(currentFieldName)) {
explain = parser.booleanValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, TRACK_SCORES_FIELD)) {
} else if (TRACK_SCORES_FIELD.match(currentFieldName)) {
trackScores = parser.booleanValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, _SOURCE_FIELD)) {
} else if (_SOURCE_FIELD.match(currentFieldName)) {
fetchSourceContext = FetchSourceContext.parse(context.parser());
} else if (context.getParseFieldMatcher().match(currentFieldName, STORED_FIELDS_FIELD)) {
} else if (STORED_FIELDS_FIELD.match(currentFieldName)) {
storedFieldsContext =
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), context);
} else if (context.getParseFieldMatcher().match(currentFieldName, SORT_FIELD)) {
} else if (SORT_FIELD.match(currentFieldName)) {
sort(parser.text());
} else if (context.getParseFieldMatcher().match(currentFieldName, PROFILE_FIELD)) {
} else if (PROFILE_FIELD.match(currentFieldName)) {
profile = parser.booleanValue();
} else if (context.getParseFieldMatcher().match(currentFieldName, FIELDS_FIELD)) {
} else if (FIELDS_FIELD.match(currentFieldName)) {
throw new ParsingException(parser.getTokenLocation(), "Deprecated field [" +
SearchSourceBuilder.FIELDS_FIELD + "] used, expected [" +
SearchSourceBuilder.STORED_FIELDS_FIELD + "] instead");
@ -965,18 +965,18 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
parser.getTokenLocation());
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
if (QUERY_FIELD.match(currentFieldName)) {
queryBuilder = context.parseInnerQueryBuilder();
} else if (context.getParseFieldMatcher().match(currentFieldName, POST_FILTER_FIELD)) {
} else if (POST_FILTER_FIELD.match(currentFieldName)) {
postQueryBuilder = context.parseInnerQueryBuilder();
} else if (context.getParseFieldMatcher().match(currentFieldName, _SOURCE_FIELD)) {
} else if (_SOURCE_FIELD.match(currentFieldName)) {
fetchSourceContext = FetchSourceContext.parse(context.parser());
} else if (context.getParseFieldMatcher().match(currentFieldName, SCRIPT_FIELDS_FIELD)) {
} else if (SCRIPT_FIELDS_FIELD.match(currentFieldName)) {
scriptFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
scriptFields.add(new ScriptField(context));
}
} else if (context.getParseFieldMatcher().match(currentFieldName, INDICES_BOOST_FIELD)) {
} else if (INDICES_BOOST_FIELD.match(currentFieldName)) {
DEPRECATION_LOGGER.deprecated(
"Object format in indices_boost is deprecated, please use array format instead");
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
@ -989,19 +989,19 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
" in [" + currentFieldName + "].", parser.getTokenLocation());
}
}
} else if (context.getParseFieldMatcher().match(currentFieldName, AGGREGATIONS_FIELD)
|| context.getParseFieldMatcher().match(currentFieldName, AGGS_FIELD)) {
} else if (AGGREGATIONS_FIELD.match(currentFieldName)
|| AGGS_FIELD.match(currentFieldName)) {
aggregations = aggParsers.parseAggregators(context);
} else if (context.getParseFieldMatcher().match(currentFieldName, HIGHLIGHT_FIELD)) {
} else if (HIGHLIGHT_FIELD.match(currentFieldName)) {
highlightBuilder = HighlightBuilder.fromXContent(context);
} else if (context.getParseFieldMatcher().match(currentFieldName, SUGGEST_FIELD)) {
} else if (SUGGEST_FIELD.match(currentFieldName)) {
suggestBuilder = SuggestBuilder.fromXContent(context, suggesters);
} else if (context.getParseFieldMatcher().match(currentFieldName, SORT_FIELD)) {
} else if (SORT_FIELD.match(currentFieldName)) {
sorts = new ArrayList<>(SortBuilder.fromXContent(context));
} else if (context.getParseFieldMatcher().match(currentFieldName, RESCORE_FIELD)) {
} else if (RESCORE_FIELD.match(currentFieldName)) {
rescoreBuilders = new ArrayList<>();
rescoreBuilders.add(RescoreBuilder.parseFromXContent(context));
} else if (context.getParseFieldMatcher().match(currentFieldName, EXT_FIELD)) {
} else if (EXT_FIELD.match(currentFieldName)) {
extBuilders = new ArrayList<>();
String extSectionName = null;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
@ -1019,16 +1019,16 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
extBuilders.add(searchExtBuilder);
}
}
} else if (context.getParseFieldMatcher().match(currentFieldName, SLICE)) {
} else if (SLICE.match(currentFieldName)) {
sliceBuilder = SliceBuilder.fromXContent(context);
} else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
parser.getTokenLocation());
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, STORED_FIELDS_FIELD)) {
if (STORED_FIELDS_FIELD.match(currentFieldName)) {
storedFieldsContext = StoredFieldsContext.fromXContent(STORED_FIELDS_FIELD.getPreferredName(), context);
} else if (context.getParseFieldMatcher().match(currentFieldName, DOCVALUE_FIELDS_FIELD)) {
} else if (DOCVALUE_FIELDS_FIELD.match(currentFieldName)) {
docValueFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) {
@ -1038,18 +1038,18 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
"] in [" + currentFieldName + "] but found [" + token + "]", parser.getTokenLocation());
}
}
} else if (context.getParseFieldMatcher().match(currentFieldName, INDICES_BOOST_FIELD)) {
} else if (INDICES_BOOST_FIELD.match(currentFieldName)) {
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
indexBoosts.add(new IndexBoost(context));
}
} else if (context.getParseFieldMatcher().match(currentFieldName, SORT_FIELD)) {
} else if (SORT_FIELD.match(currentFieldName)) {
sorts = new ArrayList<>(SortBuilder.fromXContent(context));
} else if (context.getParseFieldMatcher().match(currentFieldName, RESCORE_FIELD)) {
} else if (RESCORE_FIELD.match(currentFieldName)) {
rescoreBuilders = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
rescoreBuilders.add(RescoreBuilder.parseFromXContent(context));
}
} else if (context.getParseFieldMatcher().match(currentFieldName, STATS_FIELD)) {
} else if (STATS_FIELD.match(currentFieldName)) {
stats = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) {
@ -1059,11 +1059,11 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
"] in [" + currentFieldName + "] but found [" + token + "]", parser.getTokenLocation());
}
}
} else if (context.getParseFieldMatcher().match(currentFieldName, _SOURCE_FIELD)) {
} else if (_SOURCE_FIELD.match(currentFieldName)) {
fetchSourceContext = FetchSourceContext.parse(context.parser());
} else if (context.getParseFieldMatcher().match(currentFieldName, SEARCH_AFTER)) {
} else if (SEARCH_AFTER.match(currentFieldName)) {
searchAfterBuilder = SearchAfterBuilder.fromXContent(parser, context.getParseFieldMatcher());
} else if (context.getParseFieldMatcher().match(currentFieldName, FIELDS_FIELD)) {
} else if (FIELDS_FIELD.match(currentFieldName)) {
throw new ParsingException(parser.getTokenLocation(), "The field [" +
SearchSourceBuilder.FIELDS_FIELD + "] is no longer supported, please use [" +
SearchSourceBuilder.STORED_FIELDS_FIELD + "] to retrieve stored fields or _source filtering " +
@ -1341,16 +1341,16 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if (context.getParseFieldMatcher().match(currentFieldName, SCRIPT_FIELD)) {
if (SCRIPT_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else if (context.getParseFieldMatcher().match(currentFieldName, IGNORE_FAILURE_FIELD)) {
} else if (IGNORE_FAILURE_FIELD.match(currentFieldName)) {
ignoreFailure = parser.booleanValue();
} else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName
+ "].", parser.getTokenLocation());
}
} else if (token == XContentParser.Token.START_OBJECT) {
if (context.getParseFieldMatcher().match(currentFieldName, SCRIPT_FIELD)) {
if (SCRIPT_FIELD.match(currentFieldName)) {
script = Script.parse(parser, context.getParseFieldMatcher(), context.getDefaultScriptLanguage());
} else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName

View File

@ -111,7 +111,7 @@ public abstract class MultiValuesSourceParser<VS extends ValuesSource> implement
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
parseMissingAndAdd(aggregationName, currentFieldName, parser, missingMap);
}
} else if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
} else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
throw new ParsingException(parser.getTokenLocation(),
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "]. " +
"Multi-field aggregations do not support scripts.");
@ -121,7 +121,7 @@ public abstract class MultiValuesSourceParser<VS extends ValuesSource> implement
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "].");
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (context.getParseFieldMatcher().match(currentFieldName, Script.SCRIPT_PARSE_FIELD)) {
if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
throw new ParsingException(parser.getTokenLocation(),
"Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "]. " +
"Multi-field aggregations do not support scripts.");