Remove some usages of ParseFieldMatcher in favour of using ParseField directly (elastic/elasticsearch#4492)
Relates to elastic/elasticsearch#19552 Relates to elastic/elasticsearch#22130 Original commit: elastic/x-pack-elasticsearch@28f8e3cca4
This commit is contained in:
parent
39263d83d2
commit
37a29c0387
|
@ -114,15 +114,15 @@ public class RestGraphAction extends XPackRestHandler {
|
|||
}
|
||||
|
||||
if (token == XContentParser.Token.START_ARRAY) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, VERTICES_FIELD)) {
|
||||
if (VERTICES_FIELD.match(fieldName)) {
|
||||
parseVertices(parser, context, currentHop, graphRequest);
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, QUERY_FIELD)) {
|
||||
if (QUERY_FIELD.match(fieldName)) {
|
||||
currentHop.guidingQuery(context.parseInnerQueryBuilder());
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, CONNECTIONS_FIELD)) {
|
||||
} else if (CONNECTIONS_FIELD.match(fieldName)) {
|
||||
parseHop(parser, context, graphRequest.createNextHop(null), graphRequest);
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, CONTROLS_FIELD)) {
|
||||
} else if (CONTROLS_FIELD.match(fieldName)) {
|
||||
if (currentHop.getParentHop() != null) {
|
||||
throw new ElasticsearchParseException(
|
||||
"Controls are a global setting that can only be set in the root " + fieldName, token.name());
|
||||
|
@ -160,7 +160,7 @@ public class RestGraphAction extends XPackRestHandler {
|
|||
token = parser.nextToken();
|
||||
}
|
||||
if (token == XContentParser.Token.START_ARRAY) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, INCLUDE_FIELD)) {
|
||||
if (INCLUDE_FIELD.match(fieldName)) {
|
||||
if (excludes != null) {
|
||||
throw new ElasticsearchParseException(
|
||||
"Graph vertices definition cannot contain both "+INCLUDE_FIELD.getPreferredName()+" and "
|
||||
|
@ -176,7 +176,7 @@ public class RestGraphAction extends XPackRestHandler {
|
|||
fieldName = parser.currentName();
|
||||
} else {
|
||||
if (token == XContentParser.Token.VALUE_STRING) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, TERM_FIELD)) {
|
||||
if (TERM_FIELD.match(fieldName)) {
|
||||
includeTerm = parser.text();
|
||||
} else {
|
||||
throw new ElasticsearchParseException(
|
||||
|
@ -184,7 +184,7 @@ public class RestGraphAction extends XPackRestHandler {
|
|||
" clause has invalid property:" + fieldName);
|
||||
}
|
||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, BOOST_FIELD)) {
|
||||
if (BOOST_FIELD.match(fieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new ElasticsearchParseException(
|
||||
|
@ -215,7 +215,7 @@ public class RestGraphAction extends XPackRestHandler {
|
|||
+ token.name());
|
||||
}
|
||||
}
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, EXCLUDE_FIELD)) {
|
||||
} else if (EXCLUDE_FIELD.match(fieldName)) {
|
||||
if (includes != null) {
|
||||
throw new ElasticsearchParseException(
|
||||
"Graph vertices definition cannot contain both "+ INCLUDE_FIELD.getPreferredName()+
|
||||
|
@ -231,18 +231,18 @@ public class RestGraphAction extends XPackRestHandler {
|
|||
}
|
||||
}
|
||||
if (token == XContentParser.Token.VALUE_STRING) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, FIELD_NAME_FIELD)) {
|
||||
if (FIELD_NAME_FIELD.match(fieldName)) {
|
||||
field = parser.text();
|
||||
} else {
|
||||
throw new ElasticsearchParseException("Unknown string property: [" + fieldName + "]");
|
||||
}
|
||||
}
|
||||
if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, SIZE_FIELD)) {
|
||||
if (SIZE_FIELD.match(fieldName)) {
|
||||
size = parser.intValue();
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, MIN_DOC_COUNT_FIELD)) {
|
||||
} else if (MIN_DOC_COUNT_FIELD.match(fieldName)) {
|
||||
minDocCount = parser.intValue();
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, SHARD_MIN_DOC_COUNT_FIELD)) {
|
||||
} else if (SHARD_MIN_DOC_COUNT_FIELD.match(fieldName)) {
|
||||
shardMinDocCount = parser.intValue();
|
||||
} else {
|
||||
throw new ElasticsearchParseException("Unknown numeric property: [" + fieldName + "]");
|
||||
|
@ -282,37 +282,37 @@ public class RestGraphAction extends XPackRestHandler {
|
|||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
fieldName = parser.currentName();
|
||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, SAMPLE_SIZE_FIELD)) {
|
||||
if (SAMPLE_SIZE_FIELD.match(fieldName)) {
|
||||
graphRequest.sampleSize(parser.intValue());
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, TIMEOUT_FIELD)) {
|
||||
} else if (TIMEOUT_FIELD.match(fieldName)) {
|
||||
graphRequest.timeout(TimeValue.timeValueMillis(parser.longValue()));
|
||||
} else {
|
||||
throw new ElasticsearchParseException("Unknown numeric property: [" + fieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, SIGNIFICANCE_FIELD)) {
|
||||
if (SIGNIFICANCE_FIELD.match(fieldName)) {
|
||||
graphRequest.useSignificance(parser.booleanValue());
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, RETURN_DETAILED_INFO)) {
|
||||
} else if (RETURN_DETAILED_INFO.match(fieldName)) {
|
||||
graphRequest.returnDetailedInfo(parser.booleanValue());
|
||||
} else{
|
||||
throw new ElasticsearchParseException("Unknown boolean property: [" + fieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, TIMEOUT_FIELD)) {
|
||||
if (TIMEOUT_FIELD.match(fieldName)) {
|
||||
graphRequest.timeout(TimeValue.parseTimeValue(parser.text(), null, "timeout"));
|
||||
} else {
|
||||
throw new ElasticsearchParseException("Unknown numeric property: [" + fieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if (context.getParseFieldMatcher().match(fieldName, SAMPLE_DIVERSITY_FIELD)) {
|
||||
if (SAMPLE_DIVERSITY_FIELD.match(fieldName)) {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
fieldName = parser.currentName();
|
||||
token = parser.nextToken();
|
||||
}
|
||||
if (context.getParseFieldMatcher().match(fieldName, FIELD_NAME_FIELD)) {
|
||||
if (FIELD_NAME_FIELD.match(fieldName)) {
|
||||
graphRequest.sampleDiversityField(parser.text());
|
||||
} else if (context.getParseFieldMatcher().match(fieldName, MAX_DOCS_PER_VALUE_FIELD)) {
|
||||
} else if (MAX_DOCS_PER_VALUE_FIELD.match(fieldName)) {
|
||||
graphRequest.maxDocsPerDiversityValue(parser.intValue());
|
||||
} else {
|
||||
throw new ElasticsearchParseException("Unknown property: [" + fieldName + "]");
|
||||
|
|
Loading…
Reference in New Issue