diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 2ce9f4d47c4..20d5e64f49a 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -349,7 +349,7 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques } else if ("fields".equals(currentFieldName)) { throw new IllegalArgumentException("Action/metadata line [" + line + "] contains a simple value for parameter [fields] while a list is expected"); } else if ("_source".equals(currentFieldName)) { - fetchSourceContext = FetchSourceContext.parse(parser); + fetchSourceContext = FetchSourceContext.fromXContent(parser); } else { throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter [" + currentFieldName + "]"); } @@ -362,7 +362,7 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]"); } } else if (token == XContentParser.Token.START_OBJECT && "_source".equals(currentFieldName)) { - fetchSourceContext = FetchSourceContext.parse(parser); + fetchSourceContext = FetchSourceContext.fromXContent(parser); } else if (token != XContentParser.Token.VALUE_NULL) { throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]"); } diff --git a/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java index d31d0c9ae14..0d2801e44a0 100644 --- a/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java +++ b/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java @@ -739,7 +739,7 @@ public class UpdateRequest extends InstanceShardOperationRequest fields(fields.toArray(new String[fields.size()])); } } else if ("_source".equals(currentFieldName)) { - fetchSourceContext = FetchSourceContext.parse(parser); + fetchSourceContext = FetchSourceContext.fromXContent(parser); } } if (script != null) { diff --git a/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java b/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java index 5bd7b20cb29..9ef9f2998b0 100644 --- a/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java @@ -96,7 +96,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl ObjectParser.ValueType.OBJECT_ARRAY); PARSER.declareField((p, i, c) -> { try { - i.setFetchSourceContext(FetchSourceContext.parse(c.parser())); + i.setFetchSourceContext(FetchSourceContext.fromXContent(c.parser())); } catch (IOException e) { throw new ParsingException(p.getTokenLocation(), "Could not parse inner _source definition", e); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java index 978060632dc..68932d65b16 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java @@ -616,7 +616,7 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder scriptFields = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -699,7 +699,7 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder> sorts = SortBuilder.fromXContent(context); factory.sorts(sorts); } else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) { - factory.fetchSource(FetchSourceContext.parse(context.parser())); + factory.fetchSource(FetchSourceContext.fromXContent(context.parser())); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", parser.getTokenLocation()); diff --git a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 35c6488136b..99cb5a5e6b3 100644 --- a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -948,7 +948,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ } else if (TRACK_SCORES_FIELD.match(currentFieldName)) { trackScores = parser.booleanValue(); } else if (_SOURCE_FIELD.match(currentFieldName)) { - fetchSourceContext = FetchSourceContext.parse(context.parser()); + fetchSourceContext = FetchSourceContext.fromXContent(context.parser()); } else if (STORED_FIELDS_FIELD.match(currentFieldName)) { storedFieldsContext = StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), context); @@ -970,7 +970,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ } else if (POST_FILTER_FIELD.match(currentFieldName)) { postQueryBuilder = context.parseInnerQueryBuilder(); } else if (_SOURCE_FIELD.match(currentFieldName)) { - fetchSourceContext = FetchSourceContext.parse(context.parser()); + fetchSourceContext = FetchSourceContext.fromXContent(context.parser()); } else if (SCRIPT_FIELDS_FIELD.match(currentFieldName)) { scriptFields = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -1059,7 +1059,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ } } } else if (_SOURCE_FIELD.match(currentFieldName)) { - fetchSourceContext = FetchSourceContext.parse(context.parser()); + fetchSourceContext = FetchSourceContext.fromXContent(context.parser()); } else if (SEARCH_AFTER.match(currentFieldName)) { searchAfterBuilder = SearchAfterBuilder.fromXContent(parser, context.getParseFieldMatcher()); } else if (FIELDS_FIELD.match(currentFieldName)) { diff --git a/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java b/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java index 55197b91064..f3e8bab93fa 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java @@ -21,7 +21,6 @@ package org.elasticsearch.search.fetch.subphase; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.ParseField; -import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -55,10 +54,6 @@ public class FetchSourceContext implements Writeable, ToXContent { private final String[] excludes; private Function, Map> filter; - public static FetchSourceContext parse(XContentParser parser) throws IOException { - return fromXContent(parser, ParseFieldMatcher.STRICT); - } - public FetchSourceContext(boolean fetchSource, String[] includes, String[] excludes) { this.fetchSource = fetchSource; this.includes = includes == null ? Strings.EMPTY_ARRAY : includes; @@ -127,7 +122,7 @@ public class FetchSourceContext implements Writeable, ToXContent { return null; } - public static FetchSourceContext fromXContent(XContentParser parser, ParseFieldMatcher parseFieldMatcher) throws IOException { + public static FetchSourceContext fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); boolean fetchSource = true; String[] includes = Strings.EMPTY_ARRAY;