diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java index d067f84e3f700..68822f3f10c63 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java @@ -25,6 +25,8 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.lease.Releasable; +import org.elasticsearch.common.xcontent.DeprecationHandler; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.aggregations.bucket.BucketsAggregator; import org.elasticsearch.search.internal.SearchContext; @@ -128,10 +130,10 @@ public ParseField parseField() { return parseField; } - public static SubAggCollectionMode parse(String value) { + public static SubAggCollectionMode parse(String value, DeprecationHandler deprecationHandler) { SubAggCollectionMode[] modes = SubAggCollectionMode.values(); for (SubAggCollectionMode mode : modes) { - if (mode.parseField.match(value)) { + if (mode.parseField.match(value, deprecationHandler)) { return mode; } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java index 63490ab317f1a..262164fb4004e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java @@ -259,21 +259,21 @@ public static FiltersAggregationBuilder parse(String aggregationName, XContentPa if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_BOOLEAN) { - if (OTHER_BUCKET_FIELD.match(currentFieldName)) { + if (OTHER_BUCKET_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { 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 (OTHER_BUCKET_KEY_FIELD.match(currentFieldName)) { + if (OTHER_BUCKET_KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { 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 (FILTERS_FIELD.match(currentFieldName)) { + if (FILTERS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { keyedFilters = new ArrayList<>(); String key = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -289,7 +289,7 @@ public static FiltersAggregationBuilder parse(String aggregationName, XContentPa "Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.START_ARRAY) { - if (FILTERS_FIELD.match(currentFieldName)) { + if (FILTERS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { nonKeyedFilters = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { QueryBuilder filter = parseInnerQueryBuilder(parser); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java index f73bea0638b63..20b7eb0aed3dd 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java @@ -125,7 +125,7 @@ public static NestedAggregationBuilder parse(String aggregationName, XContentPar if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { - if (NestedAggregator.PATH_FIELD.match(currentFieldName)) { + if (NestedAggregator.PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { path = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java index d555a59071148..ee943793e349f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java @@ -181,26 +181,27 @@ private static Range parseRange(XContentParser parser) throws IOException { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_NUMBER) { - if (FROM_FIELD.match(currentFieldName)) { + if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { from = parser.doubleValue(); - } else if (TO_FIELD.match(currentFieldName)) { + } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { to = parser.doubleValue(); } else { XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); } } else if (token == XContentParser.Token.VALUE_STRING) { - if (KEY_FIELD.match(currentFieldName)) { + if (KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { key = parser.text(); - } else if (FROM_FIELD.match(currentFieldName)) { + } else if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fromAsStr = parser.text(); - } else if (TO_FIELD.match(currentFieldName)) { + } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { toAsStr = parser.text(); } else { XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); } } else if (token == XContentParser.Token.VALUE_NULL) { - if (FROM_FIELD.match(currentFieldName) || TO_FIELD.match(currentFieldName) - || KEY_FIELD.match(currentFieldName)) { + if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler()) + || TO_FIELD.match(currentFieldName, parser.getDeprecationHandler()) + || KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore null value } else { XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java index 5fc0cadcf3157..69582d49060a6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java @@ -89,13 +89,13 @@ private static Range parseRange(XContentParser parser) throws IOException { if (parser.currentToken() == Token.FIELD_NAME) { continue; } - if (RangeAggregator.Range.KEY_FIELD.match(parser.currentName())) { + if (RangeAggregator.Range.KEY_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) { key = parser.text(); - } else if (RangeAggregator.Range.FROM_FIELD.match(parser.currentName())) { + } else if (RangeAggregator.Range.FROM_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) { from = parser.textOrNull(); - } else if (RangeAggregator.Range.TO_FIELD.match(parser.currentName())) { + } else if (RangeAggregator.Range.TO_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) { to = parser.textOrNull(); - } else if (MASK_FIELD.match(parser.currentName())) { + } else if (MASK_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) { mask = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "Unexpected ip range parameter: [" + parser.currentName() + "]"); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java index 2416bf99a1194..d998beedf142d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java @@ -141,26 +141,27 @@ public static Range fromXContent(XContentParser parser) throws IOException { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_NUMBER) { - if (FROM_FIELD.match(currentFieldName)) { + if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { from = parser.doubleValue(); - } else if (TO_FIELD.match(currentFieldName)) { + } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { to = parser.doubleValue(); } else { XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); } } else if (token == XContentParser.Token.VALUE_STRING) { - if (FROM_FIELD.match(currentFieldName)) { + if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fromAsStr = parser.text(); - } else if (TO_FIELD.match(currentFieldName)) { + } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { toAsStr = parser.text(); - } else if (KEY_FIELD.match(currentFieldName)) { + } else if (KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { key = parser.text(); } else { XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); } } else if (token == XContentParser.Token.VALUE_NULL) { - if (FROM_FIELD.match(currentFieldName) || TO_FIELD.match(currentFieldName) - || KEY_FIELD.match(currentFieldName)) { + if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler()) + || TO_FIELD.match(currentFieldName, parser.getDeprecationHandler()) + || KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore null value } else { XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java index f161fd2e06f8d..ea987dcc64c93 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java @@ -107,7 +107,7 @@ public static SamplerAggregationBuilder parse(String aggregationName, XContentPa if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_NUMBER) { - if (SamplerAggregator.SHARD_SIZE_FIELD.match(currentFieldName)) { + if (SamplerAggregator.SHARD_SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { shardSize = parser.intValue(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java index ba6cece729504..59e491705c69e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java @@ -21,6 +21,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.lease.Releasables; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; @@ -112,7 +113,7 @@ boolean needsGlobalOrdinals() { public static ExecutionMode fromString(String value) { for (ExecutionMode mode : values()) { - if (mode.parseField.match(value)) { + if (mode.parseField.match(value, LoggingDeprecationHandler.INSTANCE)) { return mode; } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/GND.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/GND.java index 2c74fe1ba0124..f0347f9248b84 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/GND.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/GND.java @@ -117,7 +117,7 @@ public SignificanceHeuristic parse(XContentParser parser) throws IOException, Qu boolean backgroundIsSuperset = true; XContentParser.Token token = parser.nextToken(); while (!token.equals(XContentParser.Token.END_OBJECT)) { - if (BACKGROUND_IS_SUPERSET.match(parser.currentName())) { + if (BACKGROUND_IS_SUPERSET.match(parser.currentName(), parser.getDeprecationHandler())) { parser.nextToken(); backgroundIsSuperset = parser.booleanValue(); } else { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/NXYSignificanceHeuristic.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/NXYSignificanceHeuristic.java index f34a77d32bf83..116ac6306bb6a 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/NXYSignificanceHeuristic.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/NXYSignificanceHeuristic.java @@ -158,10 +158,10 @@ public SignificanceHeuristic parse(XContentParser parser) boolean backgroundIsSuperset = true; XContentParser.Token token = parser.nextToken(); while (!token.equals(XContentParser.Token.END_OBJECT)) { - if (INCLUDE_NEGATIVES_FIELD.match(parser.currentName())) { + if (INCLUDE_NEGATIVES_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) { parser.nextToken(); includeNegatives = parser.booleanValue(); - } else if (BACKGROUND_IS_SUPERSET.match(parser.currentName())) { + } else if (BACKGROUND_IS_SUPERSET.match(parser.currentName(), parser.getDeprecationHandler())) { parser.nextToken(); backgroundIsSuperset = parser.booleanValue(); } else { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java index 5f812ae4cc389..a2cbd49693a27 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/heuristics/ScriptHeuristic.java @@ -158,7 +158,7 @@ public static SignificanceHeuristic parse(XContentParser parser) if (token.equals(XContentParser.Token.FIELD_NAME)) { currentFieldName = parser.currentName(); } else { - if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ElasticsearchParseException("failed to parse [{}] significance heuristic. unknown object [{}]", heuristicName, currentFieldName); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java index d111c7ee80198..9e3012c5eb9d6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java @@ -104,9 +104,9 @@ public static IncludeExclude parseInclude(XContentParser parser) throws IOExcept while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); - } else if (NUM_PARTITIONS_FIELD.match(currentFieldName)) { + } else if (NUM_PARTITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { numPartitions = parser.intValue(); - } else if (PARTITION_FIELD.match(currentFieldName)) { + } else if (PARTITION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { partition = parser.intValue(); } else { throw new ElasticsearchParseException( diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java index 4a536fb681d47..3def87d7dfec0 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -82,7 +83,7 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder SubAggCollectionMode.parse(p.text()), + (p, c) -> SubAggCollectionMode.parse(p.text(), LoggingDeprecationHandler.INSTANCE), SubAggCollectionMode.KEY, ObjectParser.ValueType.STRING); PARSER.declareObjectArray(TermsAggregationBuilder::order, (p, c) -> InternalOrder.Parser.parseOrderParam(p), diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java index 34b10c9d77465..69ac175c419c8 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java @@ -255,16 +255,16 @@ public static ScriptedMetricAggregationBuilder parse(String aggregationName, XCo if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT || token == XContentParser.Token.VALUE_STRING) { - if (INIT_SCRIPT_FIELD.match(currentFieldName)) { + if (INIT_SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { initScript = Script.parse(parser); - } else if (MAP_SCRIPT_FIELD.match(currentFieldName)) { + } else if (MAP_SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { mapScript = Script.parse(parser); - } else if (COMBINE_SCRIPT_FIELD.match(currentFieldName)) { + } else if (COMBINE_SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { combineScript = Script.parse(parser); - } else if (REDUCE_SCRIPT_FIELD.match(currentFieldName)) { + } else if (REDUCE_SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { reduceScript = Script.parse(parser); } else if (token == XContentParser.Token.START_OBJECT && - PARAMS_FIELD.match(currentFieldName)) { + PARAMS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { params = parser.map(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java index 996148959db13..39e184f557dc3 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java @@ -642,31 +642,31 @@ public static TopHitsAggregationBuilder parse(String aggregationName, XContentPa if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (SearchSourceBuilder.FROM_FIELD.match(currentFieldName)) { + if (SearchSourceBuilder.FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.from(parser.intValue()); - } else if (SearchSourceBuilder.SIZE_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.size(parser.intValue()); - } else if (SearchSourceBuilder.VERSION_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.VERSION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.version(parser.booleanValue()); - } else if (SearchSourceBuilder.EXPLAIN_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.EXPLAIN_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.explain(parser.booleanValue()); - } else if (SearchSourceBuilder.TRACK_SCORES_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.TRACK_SCORES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.trackScores(parser.booleanValue()); - } else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.fetchSource(FetchSourceContext.fromXContent(parser)); - } else if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.storedFieldsContext = StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), parser); - } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { 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 (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) { + if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.fetchSource(FetchSourceContext.fromXContent(parser)); - } else if (SearchSourceBuilder.SCRIPT_FIELDS_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.SCRIPT_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List scriptFields = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { String scriptFieldName = parser.currentName(); @@ -678,9 +678,10 @@ public static TopHitsAggregationBuilder parse(String aggregationName, XContentPa if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName)) { + if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); - } else if (SearchSourceBuilder.IGNORE_FAILURE_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.IGNORE_FAILURE_FIELD.match(currentFieldName, + parser.getDeprecationHandler())) { ignoreFailure = parser.booleanValue(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -688,7 +689,7 @@ public static TopHitsAggregationBuilder parse(String aggregationName, XContentPa parser.getTokenLocation()); } } else if (token == XContentParser.Token.START_OBJECT) { - if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName)) { + if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), @@ -707,9 +708,9 @@ public static TopHitsAggregationBuilder parse(String aggregationName, XContentPa } } factory.scriptFields(scriptFields); - } else if (SearchSourceBuilder.HIGHLIGHT_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.HIGHLIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.highlighter(HighlightBuilder.fromXContent(parser)); - } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List> sorts = SortBuilder.fromXContent(parser); factory.sorts(sorts); } else { @@ -718,10 +719,10 @@ public static TopHitsAggregationBuilder parse(String aggregationName, XContentPa } } else if (token == XContentParser.Token.START_ARRAY) { - if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName)) { + if (SearchSourceBuilder.STORED_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.storedFieldsContext = StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), parser); - } else if (SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List fieldDataFields = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_STRING) { @@ -732,10 +733,10 @@ public static TopHitsAggregationBuilder parse(String aggregationName, XContentPa } } factory.fieldDataFields(fieldDataFields); - } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List> sorts = SortBuilder.fromXContent(parser); factory.sorts(sorts); - } else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) { + } else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { factory.fetchSource(FetchSourceContext.fromXContent(parser)); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java index 2e3756684446a..d2c973ebec26c 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java @@ -23,6 +23,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentLocation; import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; @@ -64,7 +65,7 @@ public enum GapPolicy { public static GapPolicy parse(String text, XContentLocation tokenLocation) { GapPolicy result = null; for (GapPolicy policy : values()) { - if (policy.parseField.match(text)) { + if (policy.parseField.match(text, LoggingDeprecationHandler.INSTANCE)) { if (result == null) { result = policy; } else { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java index d5a28100a5784..3f29a3bfdc034 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java @@ -56,17 +56,17 @@ public final BucketMetricsPipelineAggregationBuilder parse(String pipelineAgg if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { - if (FORMAT.match(currentFieldName)) { + if (FORMAT.match(currentFieldName, parser.getDeprecationHandler())) { format = parser.text(); - } else if (BUCKETS_PATH.match(currentFieldName)) { + } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { bucketsPaths = new String[] { parser.text() }; - } else if (GAP_POLICY.match(currentFieldName)) { + } else if (GAP_POLICY.match(currentFieldName, parser.getDeprecationHandler())) { gapPolicy = GapPolicy.parse(parser.text(), parser.getTokenLocation()); } else { parseToken(pipelineAggregatorName, parser, currentFieldName, token, params); } } else if (token == XContentParser.Token.START_ARRAY) { - if (BUCKETS_PATH.match(currentFieldName)) { + if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { List paths = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String path = parser.text(); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/PercentilesBucketPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/PercentilesBucketPipelineAggregationBuilder.java index a6673d3a9dacd..0870ef0e18725 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/PercentilesBucketPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/PercentilesBucketPipelineAggregationBuilder.java @@ -135,7 +135,7 @@ protected PercentilesBucketPipelineAggregationBuilder buildFactory(String pipeli @Override protected boolean token(XContentParser parser, String field, XContentParser.Token token, Map params) throws IOException { - if (PERCENTS_FIELD.match(field) && token == XContentParser.Token.START_ARRAY) { + if (PERCENTS_FIELD.match(field, parser.getDeprecationHandler()) && token == XContentParser.Token.START_ARRAY) { DoubleArrayList percents = new DoubleArrayList(10); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { percents.add(parser.doubleValue()); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/stats/extended/ExtendedStatsBucketParser.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/stats/extended/ExtendedStatsBucketParser.java index 83ad5a06fa043..d5e9e4f11e5ab 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/stats/extended/ExtendedStatsBucketParser.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/stats/extended/ExtendedStatsBucketParser.java @@ -45,7 +45,7 @@ protected ExtendedStatsBucketPipelineAggregationBuilder buildFactory(String pipe @Override protected boolean token(XContentParser parser, String field, XContentParser.Token token, Map params) throws IOException { - if (SIGMA.match(field) && token == XContentParser.Token.VALUE_NUMBER) { + if (SIGMA.match(field, parser.getDeprecationHandler()) && token == XContentParser.Token.VALUE_NUMBER) { params.put(SIGMA.getPreferredName(), parser.doubleValue()); return true; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregationBuilder.java index 7c7f1383915bb..a63fd005f9cb2 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregationBuilder.java @@ -168,21 +168,21 @@ public static BucketScriptPipelineAggregationBuilder parse(String reducerName, X if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { - if (FORMAT.match(currentFieldName)) { + if (FORMAT.match(currentFieldName, parser.getDeprecationHandler())) { format = parser.text(); - } else if (BUCKETS_PATH.match(currentFieldName)) { + } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { bucketsPathsMap = new HashMap<>(); bucketsPathsMap.put("_value", parser.text()); - } else if (GAP_POLICY.match(currentFieldName)) { + } else if (GAP_POLICY.match(currentFieldName, parser.getDeprecationHandler())) { gapPolicy = GapPolicy.parse(parser.text(), parser.getTokenLocation()); - } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.START_ARRAY) { - if (BUCKETS_PATH.match(currentFieldName)) { + if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { List paths = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String path = parser.text(); @@ -197,9 +197,9 @@ public static BucketScriptPipelineAggregationBuilder parse(String reducerName, X "Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.START_OBJECT) { - if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); - } else if (BUCKETS_PATH.match(currentFieldName)) { + } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { Map map = parser.map(); bucketsPathsMap = new HashMap<>(); for (Map.Entry entry : map.entrySet()) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketselector/BucketSelectorPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketselector/BucketSelectorPipelineAggregationBuilder.java index 219150667f63a..cb8ba81cee6ed 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketselector/BucketSelectorPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketselector/BucketSelectorPipelineAggregationBuilder.java @@ -133,19 +133,19 @@ public static BucketSelectorPipelineAggregationBuilder parse(String reducerName, if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { - if (BUCKETS_PATH.match(currentFieldName)) { + if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { bucketsPathsMap = new HashMap<>(); bucketsPathsMap.put("_value", parser.text()); - } else if (GAP_POLICY.match(currentFieldName)) { + } else if (GAP_POLICY.match(currentFieldName, parser.getDeprecationHandler())) { gapPolicy = GapPolicy.parse(parser.text(), parser.getTokenLocation()); - } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.START_ARRAY) { - if (BUCKETS_PATH.match(currentFieldName)) { + if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { List paths = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String path = parser.text(); @@ -160,9 +160,9 @@ public static BucketSelectorPipelineAggregationBuilder parse(String reducerName, "Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.START_OBJECT) { - if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); - } else if (BUCKETS_PATH.match(currentFieldName)) { + } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { Map map = parser.map(); bucketsPathsMap = new HashMap<>(); for (Map.Entry entry : map.entrySet()) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregationBuilder.java index eaf34f7e70946..dbbb7fa534a57 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregationBuilder.java @@ -140,16 +140,16 @@ public static CumulativeSumPipelineAggregationBuilder parse(String pipelineAggre if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { - if (FORMAT.match(currentFieldName)) { + if (FORMAT.match(currentFieldName, parser.getDeprecationHandler())) { format = parser.text(); - } else if (BUCKETS_PATH.match(currentFieldName)) { + } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { 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 (BUCKETS_PATH.match(currentFieldName)) { + if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { List paths = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String path = parser.text(); @@ -194,4 +194,4 @@ protected boolean doEquals(Object obj) { public String getWriteableName() { return NAME; } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregationBuilder.java index 3d2494459f6bf..ba7a2a2c03f7f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregationBuilder.java @@ -206,20 +206,20 @@ public static DerivativePipelineAggregationBuilder parse(String pipelineAggregat if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { - if (FORMAT_FIELD.match(currentFieldName)) { + if (FORMAT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { format = parser.text(); - } else if (BUCKETS_PATH_FIELD.match(currentFieldName)) { + } else if (BUCKETS_PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { bucketsPaths = new String[] { parser.text() }; - } else if (GAP_POLICY_FIELD.match(currentFieldName)) { + } else if (GAP_POLICY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { gapPolicy = GapPolicy.parse(parser.text(), parser.getTokenLocation()); - } else if (UNIT_FIELD.match(currentFieldName)) { + } else if (UNIT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { 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 (BUCKETS_PATH_FIELD.match(currentFieldName)) { + if (BUCKETS_PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List paths = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String path = parser.text(); @@ -279,4 +279,4 @@ protected int doHashCode() { public String getWriteableName() { return NAME; } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregationBuilder.java index 4fca370ab3ffd..80111a3ead524 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregationBuilder.java @@ -321,13 +321,13 @@ public static MovAvgPipelineAggregationBuilder parse( if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_NUMBER) { - if (WINDOW.match(currentFieldName)) { + if (WINDOW.match(currentFieldName, parser.getDeprecationHandler())) { 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 (PREDICT.match(currentFieldName)) { + } else if (PREDICT.match(currentFieldName, parser.getDeprecationHandler())) { predict = parser.intValue(); if (predict <= 0) { throw new ParsingException(parser.getTokenLocation(), "[" + currentFieldName + "] value must be a positive integer." @@ -338,20 +338,20 @@ public static MovAvgPipelineAggregationBuilder parse( "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.VALUE_STRING) { - if (FORMAT.match(currentFieldName)) { + if (FORMAT.match(currentFieldName, parser.getDeprecationHandler())) { format = parser.text(); - } else if (BUCKETS_PATH.match(currentFieldName)) { + } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { bucketsPaths = new String[] { parser.text() }; - } else if (GAP_POLICY.match(currentFieldName)) { + } else if (GAP_POLICY.match(currentFieldName, parser.getDeprecationHandler())) { gapPolicy = GapPolicy.parse(parser.text(), parser.getTokenLocation()); - } else if (MODEL.match(currentFieldName)) { + } else if (MODEL.match(currentFieldName, parser.getDeprecationHandler())) { 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 (BUCKETS_PATH.match(currentFieldName)) { + if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { List paths = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String path = parser.text(); @@ -363,14 +363,14 @@ public static MovAvgPipelineAggregationBuilder parse( "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.START_OBJECT) { - if (SETTINGS.match(currentFieldName)) { + if (SETTINGS.match(currentFieldName, parser.getDeprecationHandler())) { 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 (MINIMIZE.match(currentFieldName)) { + if (MINIMIZE.match(currentFieldName, parser.getDeprecationHandler())) { minimize = parser.booleanValue(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -437,4 +437,4 @@ protected boolean doEquals(Object obj) { public String getWriteableName() { return NAME; } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/HoltWintersModel.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/HoltWintersModel.java index 92b2e4d3ea26e..a750145e5f9ab 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/HoltWintersModel.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/HoltWintersModel.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregationBuilder; @@ -67,7 +68,7 @@ public static SeasonalityType parse(String text) { } SeasonalityType result = null; for (SeasonalityType policy : values()) { - if (policy.parseField.match(text)) { + if (policy.parseField.match(text, LoggingDeprecationHandler.INSTANCE)) { result = policy; break; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregationBuilder.java index b09c26cce7c5e..a7e43c401e8a6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregationBuilder.java @@ -160,18 +160,18 @@ public static SerialDiffPipelineAggregationBuilder parse(String reducerName, XCo if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { - if (FORMAT.match(currentFieldName)) { + if (FORMAT.match(currentFieldName, parser.getDeprecationHandler())) { format = parser.text(); - } else if (BUCKETS_PATH.match(currentFieldName)) { + } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { bucketsPaths = new String[] { parser.text() }; - } else if (GAP_POLICY.match(currentFieldName)) { + } else if (GAP_POLICY.match(currentFieldName, parser.getDeprecationHandler())) { gapPolicy = GapPolicy.parse(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 (LAG.match(currentFieldName)) { + if (LAG.match(currentFieldName, parser.getDeprecationHandler())) { lag = parser.intValue(true); if (lag <= 0) { throw new ParsingException(parser.getTokenLocation(), @@ -184,7 +184,7 @@ public static SerialDiffPipelineAggregationBuilder parse(String reducerName, XCo "Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.START_ARRAY) { - if (BUCKETS_PATH.match(currentFieldName)) { + if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) { List paths = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String path = parser.text(); @@ -236,4 +236,4 @@ protected boolean doEquals(Object obj) { public String getWriteableName() { return NAME; } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 4654e2bb57fde..815abf1b7a7c4 100644 --- a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -967,50 +967,50 @@ public void parseXContent(XContentParser parser) throws IOException { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (FROM_FIELD.match(currentFieldName)) { + if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { from = parser.intValue(); - } else if (SIZE_FIELD.match(currentFieldName)) { + } else if (SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { size = parser.intValue(); - } else if (TIMEOUT_FIELD.match(currentFieldName)) { + } else if (TIMEOUT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { timeout = TimeValue.parseTimeValue(parser.text(), null, TIMEOUT_FIELD.getPreferredName()); - } else if (TERMINATE_AFTER_FIELD.match(currentFieldName)) { + } else if (TERMINATE_AFTER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { terminateAfter = parser.intValue(); - } else if (MIN_SCORE_FIELD.match(currentFieldName)) { + } else if (MIN_SCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { minScore = parser.floatValue(); - } else if (VERSION_FIELD.match(currentFieldName)) { + } else if (VERSION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { version = parser.booleanValue(); - } else if (EXPLAIN_FIELD.match(currentFieldName)) { + } else if (EXPLAIN_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { explain = parser.booleanValue(); - } else if (TRACK_SCORES_FIELD.match(currentFieldName)) { + } else if (TRACK_SCORES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { trackScores = parser.booleanValue(); - } else if (TRACK_TOTAL_HITS_FIELD.match(currentFieldName)) { + } else if (TRACK_TOTAL_HITS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { trackTotalHits = parser.booleanValue(); - } else if (_SOURCE_FIELD.match(currentFieldName)) { + } else if (_SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fetchSourceContext = FetchSourceContext.fromXContent(parser); - } else if (STORED_FIELDS_FIELD.match(currentFieldName)) { + } else if (STORED_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { storedFieldsContext = StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), parser); - } else if (SORT_FIELD.match(currentFieldName)) { + } else if (SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { sort(parser.text()); - } else if (PROFILE_FIELD.match(currentFieldName)) { + } else if (PROFILE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { profile = 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 (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryBuilder = parseInnerQueryBuilder(parser); - } else if (POST_FILTER_FIELD.match(currentFieldName)) { + } else if (POST_FILTER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { postQueryBuilder = parseInnerQueryBuilder(parser); - } else if (_SOURCE_FIELD.match(currentFieldName)) { + } else if (_SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fetchSourceContext = FetchSourceContext.fromXContent(parser); - } else if (SCRIPT_FIELDS_FIELD.match(currentFieldName)) { + } else if (SCRIPT_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { scriptFields = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { scriptFields.add(new ScriptField(parser)); } - } else if (INDICES_BOOST_FIELD.match(currentFieldName)) { + } else if (INDICES_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { DEPRECATION_LOGGER.deprecated( "Object format in indices_boost is deprecated, please use array format instead"); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -1023,19 +1023,19 @@ public void parseXContent(XContentParser parser) throws IOException { " in [" + currentFieldName + "].", parser.getTokenLocation()); } } - } else if (AGGREGATIONS_FIELD.match(currentFieldName) - || AGGS_FIELD.match(currentFieldName)) { + } else if (AGGREGATIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler()) + || AGGS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { aggregations = AggregatorFactories.parseAggregators(parser); - } else if (HIGHLIGHT_FIELD.match(currentFieldName)) { + } else if (HIGHLIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { highlightBuilder = HighlightBuilder.fromXContent(parser); - } else if (SUGGEST_FIELD.match(currentFieldName)) { + } else if (SUGGEST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { suggestBuilder = SuggestBuilder.fromXContent(parser); - } else if (SORT_FIELD.match(currentFieldName)) { + } else if (SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { sorts = new ArrayList<>(SortBuilder.fromXContent(parser)); - } else if (RESCORE_FIELD.match(currentFieldName)) { + } else if (RESCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { rescoreBuilders = new ArrayList<>(); rescoreBuilders.add(RescorerBuilder.parseFromXContent(parser)); - } else if (EXT_FIELD.match(currentFieldName)) { + } else if (EXT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { extBuilders = new ArrayList<>(); String extSectionName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -1051,18 +1051,18 @@ public void parseXContent(XContentParser parser) throws IOException { extBuilders.add(searchExtBuilder); } } - } else if (SLICE.match(currentFieldName)) { + } else if (SLICE.match(currentFieldName, parser.getDeprecationHandler())) { sliceBuilder = SliceBuilder.fromXContent(parser); - } else if (COLLAPSE.match(currentFieldName)) { + } else if (COLLAPSE.match(currentFieldName, parser.getDeprecationHandler())) { collapse = CollapseBuilder.fromXContent(parser); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.START_ARRAY) { - if (STORED_FIELDS_FIELD.match(currentFieldName)) { + if (STORED_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { storedFieldsContext = StoredFieldsContext.fromXContent(STORED_FIELDS_FIELD.getPreferredName(), parser); - } else if (DOCVALUE_FIELDS_FIELD.match(currentFieldName)) { + } else if (DOCVALUE_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { docValueFields = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_STRING) { @@ -1072,18 +1072,18 @@ public void parseXContent(XContentParser parser) throws IOException { "] in [" + currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); } } - } else if (INDICES_BOOST_FIELD.match(currentFieldName)) { + } else if (INDICES_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { indexBoosts.add(new IndexBoost(parser)); } - } else if (SORT_FIELD.match(currentFieldName)) { + } else if (SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { sorts = new ArrayList<>(SortBuilder.fromXContent(parser)); - } else if (RESCORE_FIELD.match(currentFieldName)) { + } else if (RESCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { rescoreBuilders = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { rescoreBuilders.add(RescorerBuilder.parseFromXContent(parser)); } - } else if (STATS_FIELD.match(currentFieldName)) { + } else if (STATS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { stats = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_STRING) { @@ -1093,9 +1093,9 @@ public void parseXContent(XContentParser parser) throws IOException { "] in [" + currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); } } - } else if (_SOURCE_FIELD.match(currentFieldName)) { + } else if (_SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fetchSourceContext = FetchSourceContext.fromXContent(parser); - } else if (SEARCH_AFTER.match(currentFieldName)) { + } else if (SEARCH_AFTER.match(currentFieldName, parser.getDeprecationHandler())) { searchAfterBuilder = SearchAfterBuilder.fromXContent(parser); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", @@ -1373,16 +1373,16 @@ public ScriptField(XContentParser parser) throws IOException { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (SCRIPT_FIELD.match(currentFieldName)) { + if (SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); - } else if (IGNORE_FAILURE_FIELD.match(currentFieldName)) { + } else if (IGNORE_FAILURE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { 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 (SCRIPT_FIELD.match(currentFieldName)) { + if (SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java index 4ffc290f1ee89..e3c0bec6900e8 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java @@ -143,7 +143,7 @@ public static FetchSourceContext fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_ARRAY) { - if (INCLUDES_FIELD.match(currentFieldName)) { + if (INCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List includesList = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_STRING) { @@ -154,7 +154,7 @@ public static FetchSourceContext fromXContent(XContentParser parser) throws IOEx } } includes = includesList.toArray(new String[includesList.size()]); - } else if (EXCLUDES_FIELD.match(currentFieldName)) { + } else if (EXCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List excludesList = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_STRING) { @@ -170,9 +170,9 @@ public static FetchSourceContext fromXContent(XContentParser parser) throws IOEx + " in [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.VALUE_STRING) { - if (INCLUDES_FIELD.match(currentFieldName)) { + if (INCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { includes = new String[] {parser.text()}; - } else if (EXCLUDES_FIELD.match(currentFieldName)) { + } else if (EXCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { excludes = new String[] {parser.text()}; } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token diff --git a/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java b/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java index 16a2f8c8ebf4c..13dfa712ab448 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java +++ b/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java @@ -176,21 +176,21 @@ public static ProfileResult fromXContent(XContentParser parser) throws IOExcepti if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (TYPE.match(currentFieldName)) { + if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { type = parser.text(); - } else if (DESCRIPTION.match(currentFieldName)) { + } else if (DESCRIPTION.match(currentFieldName, parser.getDeprecationHandler())) { description = parser.text(); - } else if (NODE_TIME.match(currentFieldName)) { + } else if (NODE_TIME.match(currentFieldName, parser.getDeprecationHandler())) { // skip, total time is calculate by adding up 'timings' values in ProfileResult ctor parser.text(); - } else if (NODE_TIME_RAW.match(currentFieldName)) { + } else if (NODE_TIME_RAW.match(currentFieldName, parser.getDeprecationHandler())) { // skip, total time is calculate by adding up 'timings' values in ProfileResult ctor parser.longValue(); } else { parser.skipChildren(); } } else if (token == XContentParser.Token.START_OBJECT) { - if (BREAKDOWN.match(currentFieldName)) { + if (BREAKDOWN.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { ensureExpectedToken(parser.currentToken(), XContentParser.Token.FIELD_NAME, parser::getTokenLocation); String name = parser.currentName(); @@ -202,7 +202,7 @@ public static ProfileResult fromXContent(XContentParser parser) throws IOExcepti parser.skipChildren(); } } else if (token == XContentParser.Token.START_ARRAY) { - if (CHILDREN.match(currentFieldName)) { + if (CHILDREN.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { children.add(ProfileResult.fromXContent(parser)); } diff --git a/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java b/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java index 0d4ae0384baae..d553e1a8a7359 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java +++ b/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java @@ -169,20 +169,20 @@ public static CollectorResult fromXContent(XContentParser parser) throws IOExcep if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (NAME.match(currentFieldName)) { + if (NAME.match(currentFieldName, parser.getDeprecationHandler())) { name = parser.text(); - } else if (REASON.match(currentFieldName)) { + } else if (REASON.match(currentFieldName, parser.getDeprecationHandler())) { reason = parser.text(); - } else if (TIME.match(currentFieldName)) { + } else if (TIME.match(currentFieldName, parser.getDeprecationHandler())) { // we need to consume this value, but we use the raw nanosecond value parser.text(); - } else if (TIME_NANOS.match(currentFieldName)) { + } else if (TIME_NANOS.match(currentFieldName, parser.getDeprecationHandler())) { time = parser.longValue(); } else { parser.skipChildren(); } } else if (token == XContentParser.Token.START_ARRAY) { - if (CHILDREN.match(currentFieldName)) { + if (CHILDREN.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { children.add(CollectorResult.fromXContent(parser)); } diff --git a/server/src/main/java/org/elasticsearch/search/rescore/RescorerBuilder.java b/server/src/main/java/org/elasticsearch/search/rescore/RescorerBuilder.java index 531961e8d8f89..f991e9f14f07d 100644 --- a/server/src/main/java/org/elasticsearch/search/rescore/RescorerBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/rescore/RescorerBuilder.java @@ -85,7 +85,7 @@ public static RescorerBuilder parseFromXContent(XContentParser parser) throws if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } else if (token.isValue()) { - if (WINDOW_SIZE_FIELD.match(fieldName)) { + if (WINDOW_SIZE_FIELD.match(fieldName, parser.getDeprecationHandler())) { windowSize = parser.intValue(); } else { throw new ParsingException(parser.getTokenLocation(), "rescore doesn't support [" + fieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java index 8dcd2fc766f4e..1d488a58857df 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java @@ -475,10 +475,10 @@ public static GeoDistanceSortBuilder fromXContent(XContentParser parser, String fieldName = currentName; } else if (token == XContentParser.Token.START_OBJECT) { - if (NESTED_FILTER_FIELD.match(currentName)) { + if (NESTED_FILTER_FIELD.match(currentName, parser.getDeprecationHandler())) { DEPRECATION_LOGGER.deprecated("[nested_filter] has been deprecated in favour of the [nested] parameter"); nestedFilter = parseInnerQueryBuilder(parser); - } else if (NESTED_FIELD.match(currentName)) { + } else if (NESTED_FIELD.match(currentName, parser.getDeprecationHandler())) { nestedSort = NestedSortBuilder.fromXContent(parser); } else { // the json in the format of -> field : { lat : 30, lon : 12 } @@ -495,17 +495,17 @@ public static GeoDistanceSortBuilder fromXContent(XContentParser parser, String geoPoints.add(point); } } else if (token.isValue()) { - if (ORDER_FIELD.match(currentName)) { + if (ORDER_FIELD.match(currentName, parser.getDeprecationHandler())) { order = SortOrder.fromString(parser.text()); - } else if (UNIT_FIELD.match(currentName)) { + } else if (UNIT_FIELD.match(currentName, parser.getDeprecationHandler())) { unit = DistanceUnit.fromString(parser.text()); - } else if (DISTANCE_TYPE_FIELD.match(currentName)) { + } else if (DISTANCE_TYPE_FIELD.match(currentName, parser.getDeprecationHandler())) { geoDistance = GeoDistance.fromString(parser.text()); - } else if (VALIDATION_METHOD_FIELD.match(currentName)) { + } else if (VALIDATION_METHOD_FIELD.match(currentName, parser.getDeprecationHandler())) { validation = GeoValidationMethod.fromString(parser.text()); - } else if (SORTMODE_FIELD.match(currentName)) { + } else if (SORTMODE_FIELD.match(currentName, parser.getDeprecationHandler())) { sortMode = SortMode.fromString(parser.text()); - } else if (NESTED_PATH_FIELD.match(currentName)) { + } else if (NESTED_PATH_FIELD.match(currentName, parser.getDeprecationHandler())) { DEPRECATION_LOGGER.deprecated("[nested_path] has been deprecated in favour of the [nested] parameter"); nestedPath = parser.text(); } else if (token == Token.VALUE_STRING){ diff --git a/server/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java b/server/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java index 10d155eea02d1..95e6cc81b6ca1 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java @@ -151,7 +151,7 @@ public static SuggestBuilder fromXContent(XContentParser parser) throws IOExcept if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } else if (token.isValue()) { - if (GLOBAL_TEXT_FIELD.match(fieldName)) { + if (GLOBAL_TEXT_FIELD.match(fieldName, parser.getDeprecationHandler())) { suggestBuilder.setGlobalText(parser.text()); } else { throw new IllegalArgumentException("[suggest] does not support [" + fieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java b/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java index 62d93db405a2a..dcdc669539f53 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/SuggestionBuilder.java @@ -265,11 +265,11 @@ static SuggestionBuilder fromXContent(XContentParser parser) throws IOExcepti if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (TEXT_FIELD.match(currentFieldName)) { + if (TEXT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { suggestText = parser.text(); - } else if (PREFIX_FIELD.match(currentFieldName)) { + } else if (PREFIX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { prefix = parser.text(); - } else if (REGEX_FIELD.match(currentFieldName)) { + } else if (REGEX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { regex = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "suggestion does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/phrase/Laplace.java b/server/src/main/java/org/elasticsearch/search/suggest/phrase/Laplace.java index 222f69019164a..c4a6f15e03ced 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/phrase/Laplace.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/phrase/Laplace.java @@ -110,7 +110,7 @@ public static SmoothingModel fromXContent(XContentParser parser) throws IOExcept if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } - if (token.isValue() && ALPHA_FIELD.match(fieldName)) { + if (token.isValue() && ALPHA_FIELD.match(fieldName, parser.getDeprecationHandler())) { alpha = parser.doubleValue(); } } @@ -122,4 +122,4 @@ public WordScorerFactory buildWordScorerFactory() { return (IndexReader reader, Terms terms, String field, double realWordLikelyhood, BytesRef separator) -> new LaplaceScorer(reader, terms, field, realWordLikelyhood, separator, alpha); } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/suggest/phrase/LinearInterpolation.java b/server/src/main/java/org/elasticsearch/search/suggest/phrase/LinearInterpolation.java index 10a170d766dea..e609be1d77c18 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/phrase/LinearInterpolation.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/phrase/LinearInterpolation.java @@ -139,17 +139,17 @@ public static LinearInterpolation fromXContent(XContentParser parser) throws IOE if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } else if (token.isValue()) { - if (TRIGRAM_FIELD.match(fieldName)) { + if (TRIGRAM_FIELD.match(fieldName, parser.getDeprecationHandler())) { trigramLambda = parser.doubleValue(); if (trigramLambda < 0) { throw new IllegalArgumentException("trigram_lambda must be positive"); } - } else if (BIGRAM_FIELD.match(fieldName)) { + } else if (BIGRAM_FIELD.match(fieldName, parser.getDeprecationHandler())) { bigramLambda = parser.doubleValue(); if (bigramLambda < 0) { throw new IllegalArgumentException("bigram_lambda must be positive"); } - } else if (UNIGRAM_FIELD.match(fieldName)) { + } else if (UNIGRAM_FIELD.match(fieldName, parser.getDeprecationHandler())) { unigramLambda = parser.doubleValue(); if (unigramLambda < 0) { throw new IllegalArgumentException("unigram_lambda must be positive"); @@ -172,4 +172,4 @@ public WordScorerFactory buildWordScorerFactory() { new LinearInterpolatingScorer(reader, terms, field, realWordLikelyhood, separator, trigramLambda, bigramLambda, unigramLambda); } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java b/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java index 77f8fb55aa74e..4f20fad38cf0e 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java @@ -500,34 +500,34 @@ public static PhraseSuggestionBuilder fromXContent(XContentParser parser) throws if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName)) { + if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.analyzer(parser.text()); - } else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName)) { + } else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fieldname = parser.text(); - } else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName)) { + } else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.size(parser.intValue()); - } else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName)) { + } else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.shardSize(parser.intValue()); - } else if (PhraseSuggestionBuilder.RWE_LIKELIHOOD_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.RWE_LIKELIHOOD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.realWordErrorLikelihood(parser.floatValue()); - } else if (PhraseSuggestionBuilder.CONFIDENCE_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.CONFIDENCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.confidence(parser.floatValue()); - } else if (PhraseSuggestionBuilder.SEPARATOR_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.SEPARATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.separator(parser.text()); - } else if (PhraseSuggestionBuilder.MAXERRORS_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.MAXERRORS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.maxErrors(parser.floatValue()); - } else if (PhraseSuggestionBuilder.GRAMSIZE_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.GRAMSIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.gramSize(parser.intValue()); - } else if (PhraseSuggestionBuilder.FORCE_UNIGRAM_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.FORCE_UNIGRAM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.forceUnigrams(parser.booleanValue()); - } else if (PhraseSuggestionBuilder.TOKEN_LIMIT_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.TOKEN_LIMIT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.tokenLimit(parser.intValue()); } else { throw new ParsingException(parser.getTokenLocation(), "suggester[phrase] doesn't support field [" + currentFieldName + "]"); } } else if (token == Token.START_ARRAY) { - if (DirectCandidateGeneratorBuilder.DIRECT_GENERATOR_FIELD.match(currentFieldName)) { + if (DirectCandidateGeneratorBuilder.DIRECT_GENERATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // for now we only have a single type of generators while ((token = parser.nextToken()) == Token.START_OBJECT) { tmpSuggestion.addCandidateGenerator(DirectCandidateGeneratorBuilder.PARSER.apply(parser, null)); @@ -537,19 +537,19 @@ public static PhraseSuggestionBuilder fromXContent(XContentParser parser) throws "suggester[phrase] doesn't support array field [" + currentFieldName + "]"); } } else if (token == Token.START_OBJECT) { - if (PhraseSuggestionBuilder.SMOOTHING_MODEL_FIELD.match(currentFieldName)) { + if (PhraseSuggestionBuilder.SMOOTHING_MODEL_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ensureNoSmoothing(tmpSuggestion); tmpSuggestion.smoothingModel(SmoothingModel.fromXContent(parser)); - } else if (PhraseSuggestionBuilder.HIGHLIGHT_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.HIGHLIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String preTag = null; String postTag = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (PhraseSuggestionBuilder.PRE_TAG_FIELD.match(currentFieldName)) { + if (PhraseSuggestionBuilder.PRE_TAG_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { preTag = parser.text(); - } else if (PhraseSuggestionBuilder.POST_TAG_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.POST_TAG_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { postTag = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -558,11 +558,11 @@ public static PhraseSuggestionBuilder fromXContent(XContentParser parser) throws } } tmpSuggestion.highlight(preTag, postTag); - } else if (PhraseSuggestionBuilder.COLLATE_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.COLLATE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); - } else if (PhraseSuggestionBuilder.COLLATE_QUERY_FIELD.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.COLLATE_QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (tmpSuggestion.collateQuery() != null) { throw new ParsingException(parser.getTokenLocation(), "suggester[phrase][collate] query already set, doesn't support additional [" @@ -570,9 +570,9 @@ public static PhraseSuggestionBuilder fromXContent(XContentParser parser) throws } Script template = Script.parse(parser, Script.DEFAULT_TEMPLATE_LANG); tmpSuggestion.collateQuery(template); - } else if (PhraseSuggestionBuilder.COLLATE_QUERY_PARAMS.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.COLLATE_QUERY_PARAMS.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.collateParams(parser.map()); - } else if (PhraseSuggestionBuilder.COLLATE_QUERY_PRUNE.match(currentFieldName)) { + } else if (PhraseSuggestionBuilder.COLLATE_QUERY_PRUNE.match(currentFieldName, parser.getDeprecationHandler())) { if (parser.isBooleanValue()) { tmpSuggestion.collatePrune(parser.booleanValue()); } else { diff --git a/server/src/main/java/org/elasticsearch/search/suggest/phrase/SmoothingModel.java b/server/src/main/java/org/elasticsearch/search/suggest/phrase/SmoothingModel.java index f0fbc81ecd7f0..9c81f86058024 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/phrase/SmoothingModel.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/phrase/SmoothingModel.java @@ -72,11 +72,11 @@ public static SmoothingModel fromXContent(XContentParser parser) throws IOExcept if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (LinearInterpolation.PARSE_FIELD.match(fieldName)) { + if (LinearInterpolation.PARSE_FIELD.match(fieldName, parser.getDeprecationHandler())) { model = LinearInterpolation.fromXContent(parser); - } else if (Laplace.PARSE_FIELD.match(fieldName)) { + } else if (Laplace.PARSE_FIELD.match(fieldName, parser.getDeprecationHandler())) { model = Laplace.fromXContent(parser); - } else if (StupidBackoff.PARSE_FIELD.match(fieldName)) { + } else if (StupidBackoff.PARSE_FIELD.match(fieldName, parser.getDeprecationHandler())) { model = StupidBackoff.fromXContent(parser); } else { throw new IllegalArgumentException("suggester[phrase] doesn't support object field [" + fieldName + "]"); @@ -97,4 +97,4 @@ public static SmoothingModel fromXContent(XContentParser parser) throws IOExcept protected abstract boolean doEquals(SmoothingModel other); protected abstract XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException; -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/suggest/phrase/StupidBackoff.java b/server/src/main/java/org/elasticsearch/search/suggest/phrase/StupidBackoff.java index ebdd1c9ec2892..c7edde8bbaf76 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/phrase/StupidBackoff.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/phrase/StupidBackoff.java @@ -113,7 +113,7 @@ public static SmoothingModel fromXContent(XContentParser parser) throws IOExcept if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } - if (token.isValue() && DISCOUNT_FIELD.match(fieldName)) { + if (token.isValue() && DISCOUNT_FIELD.match(fieldName, parser.getDeprecationHandler())) { discount = parser.doubleValue(); } } @@ -125,4 +125,4 @@ public WordScorerFactory buildWordScorerFactory() { return (IndexReader reader, Terms terms, String field, double realWordLikelyhood, BytesRef separator) -> new StupidBackoffScorer(reader, terms, field, realWordLikelyhood, separator, discount); } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilder.java b/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilder.java index b0d9891087f08..5d004dc824777 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilder.java @@ -396,33 +396,33 @@ public static TermSuggestionBuilder fromXContent(XContentParser parser) throws I if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName)) { + if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.analyzer(parser.text()); - } else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName)) { + } else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fieldname = parser.text(); - } else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName)) { + } else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.size(parser.intValue()); - } else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName)) { + } else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.shardSize(parser.intValue()); - } else if (SUGGESTMODE_FIELD.match(currentFieldName)) { + } else if (SUGGESTMODE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.suggestMode(SuggestMode.resolve(parser.text())); - } else if (ACCURACY_FIELD.match(currentFieldName)) { + } else if (ACCURACY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.accuracy(parser.floatValue()); - } else if (SORT_FIELD.match(currentFieldName)) { + } else if (SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.sort(SortBy.resolve(parser.text())); - } else if (STRING_DISTANCE_FIELD.match(currentFieldName)) { + } else if (STRING_DISTANCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.stringDistance(StringDistanceImpl.resolve(parser.text())); - } else if (MAX_EDITS_FIELD.match(currentFieldName)) { + } else if (MAX_EDITS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.maxEdits(parser.intValue()); - } else if (MAX_INSPECTIONS_FIELD.match(currentFieldName)) { + } else if (MAX_INSPECTIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.maxInspections(parser.intValue()); - } else if (MAX_TERM_FREQ_FIELD.match(currentFieldName)) { + } else if (MAX_TERM_FREQ_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.maxTermFreq(parser.floatValue()); - } else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) { + } else if (PREFIX_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.prefixLength(parser.intValue()); - } else if (MIN_WORD_LENGTH_FIELD.match(currentFieldName)) { + } else if (MIN_WORD_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.minWordLength(parser.intValue()); - } else if (MIN_DOC_FREQ_FIELD.match(currentFieldName)) { + } else if (MIN_DOC_FREQ_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tmpSuggestion.minDocFreq(parser.floatValue()); } else { throw new ParsingException(parser.getTokenLocation(),