Switch to non-deprecated ParseField.match method for o.e.search (#28526)

* Switch to non-deprecated ParseField.match method for o.e.search

This replaces more of the `ParseField.match` calls with the same call using a
deprecation handler. It encapsulates all of the instances in the
`org.elastsicsearch.search` package.

Relates to #28504

* Address Nik's comments
This commit is contained in:
Lee Hinman 2018-02-08 11:17:57 -07:00 committed by GitHub
parent 0edde25f09
commit 2e4c834a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 226 additions and 217 deletions

View File

@ -25,6 +25,8 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.lease.Releasable; 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.common.xcontent.XContentParser;
import org.elasticsearch.search.aggregations.bucket.BucketsAggregator; import org.elasticsearch.search.aggregations.bucket.BucketsAggregator;
import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.SearchContext;
@ -128,10 +130,10 @@ public abstract class Aggregator extends BucketCollector implements Releasable {
return parseField; return parseField;
} }
public static SubAggCollectionMode parse(String value) { public static SubAggCollectionMode parse(String value, DeprecationHandler deprecationHandler) {
SubAggCollectionMode[] modes = SubAggCollectionMode.values(); SubAggCollectionMode[] modes = SubAggCollectionMode.values();
for (SubAggCollectionMode mode : modes) { for (SubAggCollectionMode mode : modes) {
if (mode.parseField.match(value)) { if (mode.parseField.match(value, deprecationHandler)) {
return mode; return mode;
} }
} }

View File

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

View File

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

View File

@ -181,26 +181,27 @@ public class GeoDistanceAggregationBuilder extends ValuesSourceAggregationBuilde
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_NUMBER) { } else if (token == XContentParser.Token.VALUE_NUMBER) {
if (FROM_FIELD.match(currentFieldName)) { if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
from = parser.doubleValue(); from = parser.doubleValue();
} else if (TO_FIELD.match(currentFieldName)) { } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
to = parser.doubleValue(); to = parser.doubleValue();
} else { } else {
XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.VALUE_STRING) { } else if (token == XContentParser.Token.VALUE_STRING) {
if (KEY_FIELD.match(currentFieldName)) { if (KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
key = parser.text(); key = parser.text();
} else if (FROM_FIELD.match(currentFieldName)) { } else if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
fromAsStr = parser.text(); fromAsStr = parser.text();
} else if (TO_FIELD.match(currentFieldName)) { } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
toAsStr = parser.text(); toAsStr = parser.text();
} else { } else {
XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.VALUE_NULL) { } else if (token == XContentParser.Token.VALUE_NULL) {
if (FROM_FIELD.match(currentFieldName) || TO_FIELD.match(currentFieldName) if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())
|| KEY_FIELD.match(currentFieldName)) { || TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())
|| KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
// ignore null value // ignore null value
} else { } else {
XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation());

View File

@ -89,13 +89,13 @@ public final class IpRangeAggregationBuilder
if (parser.currentToken() == Token.FIELD_NAME) { if (parser.currentToken() == Token.FIELD_NAME) {
continue; continue;
} }
if (RangeAggregator.Range.KEY_FIELD.match(parser.currentName())) { if (RangeAggregator.Range.KEY_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) {
key = parser.text(); 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(); 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(); to = parser.textOrNull();
} else if (MASK_FIELD.match(parser.currentName())) { } else if (MASK_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) {
mask = parser.text(); mask = parser.text();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unexpected ip range parameter: [" + parser.currentName() + "]"); throw new ParsingException(parser.getTokenLocation(), "Unexpected ip range parameter: [" + parser.currentName() + "]");

View File

@ -141,26 +141,27 @@ public class RangeAggregator extends BucketsAggregator {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_NUMBER) { } else if (token == XContentParser.Token.VALUE_NUMBER) {
if (FROM_FIELD.match(currentFieldName)) { if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
from = parser.doubleValue(); from = parser.doubleValue();
} else if (TO_FIELD.match(currentFieldName)) { } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
to = parser.doubleValue(); to = parser.doubleValue();
} else { } else {
XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.VALUE_STRING) { } else if (token == XContentParser.Token.VALUE_STRING) {
if (FROM_FIELD.match(currentFieldName)) { if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
fromAsStr = parser.text(); fromAsStr = parser.text();
} else if (TO_FIELD.match(currentFieldName)) { } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
toAsStr = parser.text(); toAsStr = parser.text();
} else if (KEY_FIELD.match(currentFieldName)) { } else if (KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
key = parser.text(); key = parser.text();
} else { } else {
XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.VALUE_NULL) { } else if (token == XContentParser.Token.VALUE_NULL) {
if (FROM_FIELD.match(currentFieldName) || TO_FIELD.match(currentFieldName) if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())
|| KEY_FIELD.match(currentFieldName)) { || TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())
|| KEY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
// ignore null value // ignore null value
} else { } else {
XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation()); XContentParserUtils.throwUnknownField(currentFieldName, parser.getTokenLocation());

View File

@ -107,7 +107,7 @@ public class SamplerAggregationBuilder extends AbstractAggregationBuilder<Sample
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_NUMBER) { } 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(); shardSize = parser.intValue();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),

View File

@ -21,6 +21,7 @@ package org.elasticsearch.search.aggregations.bucket.sampler;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.lease.Releasables; import org.elasticsearch.common.lease.Releasables;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.Aggregator;
import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactories;
@ -112,7 +113,7 @@ public class SamplerAggregator extends DeferableBucketAggregator implements Sing
public static ExecutionMode fromString(String value) { public static ExecutionMode fromString(String value) {
for (ExecutionMode mode : values()) { for (ExecutionMode mode : values()) {
if (mode.parseField.match(value)) { if (mode.parseField.match(value, LoggingDeprecationHandler.INSTANCE)) {
return mode; return mode;
} }
} }

View File

@ -117,7 +117,7 @@ public class GND extends NXYSignificanceHeuristic {
boolean backgroundIsSuperset = true; boolean backgroundIsSuperset = true;
XContentParser.Token token = parser.nextToken(); XContentParser.Token token = parser.nextToken();
while (!token.equals(XContentParser.Token.END_OBJECT)) { 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(); parser.nextToken();
backgroundIsSuperset = parser.booleanValue(); backgroundIsSuperset = parser.booleanValue();
} else { } else {

View File

@ -158,10 +158,10 @@ public abstract class NXYSignificanceHeuristic extends SignificanceHeuristic {
boolean backgroundIsSuperset = true; boolean backgroundIsSuperset = true;
XContentParser.Token token = parser.nextToken(); XContentParser.Token token = parser.nextToken();
while (!token.equals(XContentParser.Token.END_OBJECT)) { 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(); parser.nextToken();
includeNegatives = parser.booleanValue(); includeNegatives = parser.booleanValue();
} else if (BACKGROUND_IS_SUPERSET.match(parser.currentName())) { } else if (BACKGROUND_IS_SUPERSET.match(parser.currentName(), parser.getDeprecationHandler())) {
parser.nextToken(); parser.nextToken();
backgroundIsSuperset = parser.booleanValue(); backgroundIsSuperset = parser.booleanValue();
} else { } else {

View File

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

View File

@ -104,9 +104,9 @@ public class IncludeExclude implements Writeable, ToXContentFragment {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (NUM_PARTITIONS_FIELD.match(currentFieldName)) { } else if (NUM_PARTITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
numPartitions = parser.intValue(); numPartitions = parser.intValue();
} else if (PARTITION_FIELD.match(currentFieldName)) { } else if (PARTITION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
partition = parser.intValue(); partition = parser.intValue();
} else { } else {
throw new ElasticsearchParseException( throw new ElasticsearchParseException(

View File

@ -21,6 +21,7 @@ package org.elasticsearch.search.aggregations.bucket.terms;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
@ -82,7 +83,7 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Valu
PARSER.declareString(TermsAggregationBuilder::executionHint, EXECUTION_HINT_FIELD_NAME); PARSER.declareString(TermsAggregationBuilder::executionHint, EXECUTION_HINT_FIELD_NAME);
PARSER.declareField(TermsAggregationBuilder::collectMode, PARSER.declareField(TermsAggregationBuilder::collectMode,
(p, c) -> SubAggCollectionMode.parse(p.text()), (p, c) -> SubAggCollectionMode.parse(p.text(), LoggingDeprecationHandler.INSTANCE),
SubAggCollectionMode.KEY, ObjectParser.ValueType.STRING); SubAggCollectionMode.KEY, ObjectParser.ValueType.STRING);
PARSER.declareObjectArray(TermsAggregationBuilder::order, (p, c) -> InternalOrder.Parser.parseOrderParam(p), PARSER.declareObjectArray(TermsAggregationBuilder::order, (p, c) -> InternalOrder.Parser.parseOrderParam(p),

View File

@ -255,16 +255,16 @@ public class ScriptedMetricAggregationBuilder extends AbstractAggregationBuilder
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT || token == XContentParser.Token.VALUE_STRING) { } 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); initScript = Script.parse(parser);
} else if (MAP_SCRIPT_FIELD.match(currentFieldName)) { } else if (MAP_SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
mapScript = Script.parse(parser); mapScript = Script.parse(parser);
} else if (COMBINE_SCRIPT_FIELD.match(currentFieldName)) { } else if (COMBINE_SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
combineScript = Script.parse(parser); combineScript = Script.parse(parser);
} else if (REDUCE_SCRIPT_FIELD.match(currentFieldName)) { } else if (REDUCE_SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
reduceScript = Script.parse(parser); reduceScript = Script.parse(parser);
} else if (token == XContentParser.Token.START_OBJECT && } else if (token == XContentParser.Token.START_OBJECT &&
PARAMS_FIELD.match(currentFieldName)) { PARAMS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
params = parser.map(); params = parser.map();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),

View File

@ -642,31 +642,31 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (SearchSourceBuilder.FROM_FIELD.match(currentFieldName)) { if (SearchSourceBuilder.FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
factory.from(parser.intValue()); factory.from(parser.intValue());
} else if (SearchSourceBuilder.SIZE_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder.SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
factory.size(parser.intValue()); factory.size(parser.intValue());
} else if (SearchSourceBuilder.VERSION_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder.VERSION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
factory.version(parser.booleanValue()); factory.version(parser.booleanValue());
} else if (SearchSourceBuilder.EXPLAIN_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder.EXPLAIN_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
factory.explain(parser.booleanValue()); 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()); 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)); 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 = factory.storedFieldsContext =
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), parser); 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()); factory.sort(parser.text());
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
parser.getTokenLocation()); parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.START_OBJECT) { } 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)); factory.fetchSource(FetchSourceContext.fromXContent(parser));
} else if (SearchSourceBuilder.SCRIPT_FIELDS_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder.SCRIPT_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
List<ScriptField> scriptFields = new ArrayList<>(); List<ScriptField> scriptFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
String scriptFieldName = parser.currentName(); String scriptFieldName = parser.currentName();
@ -678,9 +678,10 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName)) { if (SearchSourceBuilder.SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
script = Script.parse(parser); 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(); ignoreFailure = parser.booleanValue();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),
@ -688,7 +689,7 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
parser.getTokenLocation()); parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.START_OBJECT) { } 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); script = Script.parse(parser);
} else { } else {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),
@ -707,9 +708,9 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
} }
} }
factory.scriptFields(scriptFields); factory.scriptFields(scriptFields);
} else if (SearchSourceBuilder.HIGHLIGHT_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder.HIGHLIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
factory.highlighter(HighlightBuilder.fromXContent(parser)); factory.highlighter(HighlightBuilder.fromXContent(parser));
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
List<SortBuilder<?>> sorts = SortBuilder.fromXContent(parser); List<SortBuilder<?>> sorts = SortBuilder.fromXContent(parser);
factory.sorts(sorts); factory.sorts(sorts);
} else { } else {
@ -718,10 +719,10 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
} }
} else if (token == XContentParser.Token.START_ARRAY) { } 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 = factory.storedFieldsContext =
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), parser); 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<String> fieldDataFields = new ArrayList<>(); List<String> fieldDataFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
@ -732,10 +733,10 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
} }
} }
factory.fieldDataFields(fieldDataFields); factory.fieldDataFields(fieldDataFields);
} else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder.SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
List<SortBuilder<?>> sorts = SortBuilder.fromXContent(parser); List<SortBuilder<?>> sorts = SortBuilder.fromXContent(parser);
factory.sorts(sorts); factory.sorts(sorts);
} else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName)) { } else if (SearchSourceBuilder._SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
factory.fetchSource(FetchSourceContext.fromXContent(parser)); factory.fetchSource(FetchSourceContext.fromXContent(parser));
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",

View File

@ -23,6 +23,7 @@ import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.XContentLocation; import org.elasticsearch.common.xcontent.XContentLocation;
import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation;
@ -64,7 +65,7 @@ public class BucketHelpers {
public static GapPolicy parse(String text, XContentLocation tokenLocation) { public static GapPolicy parse(String text, XContentLocation tokenLocation) {
GapPolicy result = null; GapPolicy result = null;
for (GapPolicy policy : values()) { for (GapPolicy policy : values()) {
if (policy.parseField.match(text)) { if (policy.parseField.match(text, LoggingDeprecationHandler.INSTANCE)) {
if (result == null) { if (result == null) {
result = policy; result = policy;
} else { } else {

View File

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

View File

@ -135,7 +135,7 @@ public class PercentilesBucketPipelineAggregationBuilder
@Override @Override
protected boolean token(XContentParser parser, String field, XContentParser.Token token, Map<String, Object> params) protected boolean token(XContentParser parser, String field, XContentParser.Token token, Map<String, Object> params)
throws IOException { 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); DoubleArrayList percents = new DoubleArrayList(10);
while (parser.nextToken() != XContentParser.Token.END_ARRAY) { while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
percents.add(parser.doubleValue()); percents.add(parser.doubleValue());

View File

@ -45,7 +45,7 @@ public class ExtendedStatsBucketParser extends BucketMetricsParser {
@Override @Override
protected boolean token(XContentParser parser, String field, protected boolean token(XContentParser parser, String field,
XContentParser.Token token, Map<String, Object> params) throws IOException { XContentParser.Token token, Map<String, Object> 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()); params.put(SIGMA.getPreferredName(), parser.doubleValue());
return true; return true;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,6 +25,7 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregationBuilder; import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregationBuilder;
@ -67,7 +68,7 @@ public class HoltWintersModel extends MovAvgModel {
} }
SeasonalityType result = null; SeasonalityType result = null;
for (SeasonalityType policy : values()) { for (SeasonalityType policy : values()) {
if (policy.parseField.match(text)) { if (policy.parseField.match(text, LoggingDeprecationHandler.INSTANCE)) {
result = policy; result = policy;
break; break;
} }

View File

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

View File

@ -967,50 +967,50 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (FROM_FIELD.match(currentFieldName)) { if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
from = parser.intValue(); from = parser.intValue();
} else if (SIZE_FIELD.match(currentFieldName)) { } else if (SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
size = parser.intValue(); 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()); 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(); terminateAfter = parser.intValue();
} else if (MIN_SCORE_FIELD.match(currentFieldName)) { } else if (MIN_SCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
minScore = parser.floatValue(); minScore = parser.floatValue();
} else if (VERSION_FIELD.match(currentFieldName)) { } else if (VERSION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
version = parser.booleanValue(); version = parser.booleanValue();
} else if (EXPLAIN_FIELD.match(currentFieldName)) { } else if (EXPLAIN_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
explain = parser.booleanValue(); explain = parser.booleanValue();
} else if (TRACK_SCORES_FIELD.match(currentFieldName)) { } else if (TRACK_SCORES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
trackScores = parser.booleanValue(); trackScores = parser.booleanValue();
} else if (TRACK_TOTAL_HITS_FIELD.match(currentFieldName)) { } else if (TRACK_TOTAL_HITS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
trackTotalHits = parser.booleanValue(); trackTotalHits = parser.booleanValue();
} else if (_SOURCE_FIELD.match(currentFieldName)) { } else if (_SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
fetchSourceContext = FetchSourceContext.fromXContent(parser); fetchSourceContext = FetchSourceContext.fromXContent(parser);
} else if (STORED_FIELDS_FIELD.match(currentFieldName)) { } else if (STORED_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
storedFieldsContext = storedFieldsContext =
StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), parser); 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()); sort(parser.text());
} else if (PROFILE_FIELD.match(currentFieldName)) { } else if (PROFILE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
profile = parser.booleanValue(); profile = parser.booleanValue();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
parser.getTokenLocation()); parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if (QUERY_FIELD.match(currentFieldName)) { if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
queryBuilder = parseInnerQueryBuilder(parser); queryBuilder = parseInnerQueryBuilder(parser);
} else if (POST_FILTER_FIELD.match(currentFieldName)) { } else if (POST_FILTER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
postQueryBuilder = parseInnerQueryBuilder(parser); postQueryBuilder = parseInnerQueryBuilder(parser);
} else if (_SOURCE_FIELD.match(currentFieldName)) { } else if (_SOURCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
fetchSourceContext = FetchSourceContext.fromXContent(parser); fetchSourceContext = FetchSourceContext.fromXContent(parser);
} else if (SCRIPT_FIELDS_FIELD.match(currentFieldName)) { } else if (SCRIPT_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
scriptFields = new ArrayList<>(); scriptFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
scriptFields.add(new ScriptField(parser)); scriptFields.add(new ScriptField(parser));
} }
} else if (INDICES_BOOST_FIELD.match(currentFieldName)) { } else if (INDICES_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
DEPRECATION_LOGGER.deprecated( DEPRECATION_LOGGER.deprecated(
"Object format in indices_boost is deprecated, please use array format instead"); "Object format in indices_boost is deprecated, please use array format instead");
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
@ -1023,19 +1023,19 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
" in [" + currentFieldName + "].", parser.getTokenLocation()); " in [" + currentFieldName + "].", parser.getTokenLocation());
} }
} }
} else if (AGGREGATIONS_FIELD.match(currentFieldName) } else if (AGGREGATIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())
|| AGGS_FIELD.match(currentFieldName)) { || AGGS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
aggregations = AggregatorFactories.parseAggregators(parser); aggregations = AggregatorFactories.parseAggregators(parser);
} else if (HIGHLIGHT_FIELD.match(currentFieldName)) { } else if (HIGHLIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
highlightBuilder = HighlightBuilder.fromXContent(parser); highlightBuilder = HighlightBuilder.fromXContent(parser);
} else if (SUGGEST_FIELD.match(currentFieldName)) { } else if (SUGGEST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
suggestBuilder = SuggestBuilder.fromXContent(parser); suggestBuilder = SuggestBuilder.fromXContent(parser);
} else if (SORT_FIELD.match(currentFieldName)) { } else if (SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
sorts = new ArrayList<>(SortBuilder.fromXContent(parser)); sorts = new ArrayList<>(SortBuilder.fromXContent(parser));
} else if (RESCORE_FIELD.match(currentFieldName)) { } else if (RESCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
rescoreBuilders = new ArrayList<>(); rescoreBuilders = new ArrayList<>();
rescoreBuilders.add(RescorerBuilder.parseFromXContent(parser)); rescoreBuilders.add(RescorerBuilder.parseFromXContent(parser));
} else if (EXT_FIELD.match(currentFieldName)) { } else if (EXT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
extBuilders = new ArrayList<>(); extBuilders = new ArrayList<>();
String extSectionName = null; String extSectionName = null;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
@ -1051,18 +1051,18 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
extBuilders.add(searchExtBuilder); extBuilders.add(searchExtBuilder);
} }
} }
} else if (SLICE.match(currentFieldName)) { } else if (SLICE.match(currentFieldName, parser.getDeprecationHandler())) {
sliceBuilder = SliceBuilder.fromXContent(parser); sliceBuilder = SliceBuilder.fromXContent(parser);
} else if (COLLAPSE.match(currentFieldName)) { } else if (COLLAPSE.match(currentFieldName, parser.getDeprecationHandler())) {
collapse = CollapseBuilder.fromXContent(parser); collapse = CollapseBuilder.fromXContent(parser);
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
parser.getTokenLocation()); parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.START_ARRAY) { } 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); 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<>(); docValueFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
@ -1072,18 +1072,18 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
"] in [" + currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); "] 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) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
indexBoosts.add(new IndexBoost(parser)); 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)); sorts = new ArrayList<>(SortBuilder.fromXContent(parser));
} else if (RESCORE_FIELD.match(currentFieldName)) { } else if (RESCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
rescoreBuilders = new ArrayList<>(); rescoreBuilders = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
rescoreBuilders.add(RescorerBuilder.parseFromXContent(parser)); rescoreBuilders.add(RescorerBuilder.parseFromXContent(parser));
} }
} else if (STATS_FIELD.match(currentFieldName)) { } else if (STATS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
stats = new ArrayList<>(); stats = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
@ -1093,9 +1093,9 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
"] in [" + currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); "] 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); fetchSourceContext = FetchSourceContext.fromXContent(parser);
} else if (SEARCH_AFTER.match(currentFieldName)) { } else if (SEARCH_AFTER.match(currentFieldName, parser.getDeprecationHandler())) {
searchAfterBuilder = SearchAfterBuilder.fromXContent(parser); searchAfterBuilder = SearchAfterBuilder.fromXContent(parser);
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
@ -1373,16 +1373,16 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (SCRIPT_FIELD.match(currentFieldName)) { if (SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
script = Script.parse(parser); script = Script.parse(parser);
} else if (IGNORE_FAILURE_FIELD.match(currentFieldName)) { } else if (IGNORE_FAILURE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
ignoreFailure = parser.booleanValue(); ignoreFailure = parser.booleanValue();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName
+ "].", parser.getTokenLocation()); + "].", parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if (SCRIPT_FIELD.match(currentFieldName)) { if (SCRIPT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
script = Script.parse(parser); script = Script.parse(parser);
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName

View File

@ -143,7 +143,7 @@ public class FetchSourceContext implements Writeable, ToXContentObject {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_ARRAY) { } else if (token == XContentParser.Token.START_ARRAY) {
if (INCLUDES_FIELD.match(currentFieldName)) { if (INCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
List<String> includesList = new ArrayList<>(); List<String> includesList = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
@ -154,7 +154,7 @@ public class FetchSourceContext implements Writeable, ToXContentObject {
} }
} }
includes = includesList.toArray(new String[includesList.size()]); includes = includesList.toArray(new String[includesList.size()]);
} else if (EXCLUDES_FIELD.match(currentFieldName)) { } else if (EXCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
List<String> excludesList = new ArrayList<>(); List<String> excludesList = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
@ -170,9 +170,9 @@ public class FetchSourceContext implements Writeable, ToXContentObject {
+ " in [" + currentFieldName + "].", parser.getTokenLocation()); + " in [" + currentFieldName + "].", parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.VALUE_STRING) { } else if (token == XContentParser.Token.VALUE_STRING) {
if (INCLUDES_FIELD.match(currentFieldName)) { if (INCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
includes = new String[] {parser.text()}; includes = new String[] {parser.text()};
} else if (EXCLUDES_FIELD.match(currentFieldName)) { } else if (EXCLUDES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
excludes = new String[] {parser.text()}; excludes = new String[] {parser.text()};
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token

View File

@ -176,21 +176,21 @@ public final class ProfileResult implements Writeable, ToXContentObject {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (TYPE.match(currentFieldName)) { if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
type = parser.text(); type = parser.text();
} else if (DESCRIPTION.match(currentFieldName)) { } else if (DESCRIPTION.match(currentFieldName, parser.getDeprecationHandler())) {
description = parser.text(); 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 // skip, total time is calculate by adding up 'timings' values in ProfileResult ctor
parser.text(); 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 // skip, total time is calculate by adding up 'timings' values in ProfileResult ctor
parser.longValue(); parser.longValue();
} else { } else {
parser.skipChildren(); parser.skipChildren();
} }
} else if (token == XContentParser.Token.START_OBJECT) { } 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) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
ensureExpectedToken(parser.currentToken(), XContentParser.Token.FIELD_NAME, parser::getTokenLocation); ensureExpectedToken(parser.currentToken(), XContentParser.Token.FIELD_NAME, parser::getTokenLocation);
String name = parser.currentName(); String name = parser.currentName();
@ -202,7 +202,7 @@ public final class ProfileResult implements Writeable, ToXContentObject {
parser.skipChildren(); parser.skipChildren();
} }
} else if (token == XContentParser.Token.START_ARRAY) { } 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) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
children.add(ProfileResult.fromXContent(parser)); children.add(ProfileResult.fromXContent(parser));
} }

View File

@ -169,20 +169,20 @@ public class CollectorResult implements ToXContentObject, Writeable {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (NAME.match(currentFieldName)) { if (NAME.match(currentFieldName, parser.getDeprecationHandler())) {
name = parser.text(); name = parser.text();
} else if (REASON.match(currentFieldName)) { } else if (REASON.match(currentFieldName, parser.getDeprecationHandler())) {
reason = parser.text(); 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 // we need to consume this value, but we use the raw nanosecond value
parser.text(); parser.text();
} else if (TIME_NANOS.match(currentFieldName)) { } else if (TIME_NANOS.match(currentFieldName, parser.getDeprecationHandler())) {
time = parser.longValue(); time = parser.longValue();
} else { } else {
parser.skipChildren(); parser.skipChildren();
} }
} else if (token == XContentParser.Token.START_ARRAY) { } 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) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
children.add(CollectorResult.fromXContent(parser)); children.add(CollectorResult.fromXContent(parser));
} }

View File

@ -85,7 +85,7 @@ public abstract class RescorerBuilder<RB extends RescorerBuilder<RB>>
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName(); fieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (WINDOW_SIZE_FIELD.match(fieldName)) { if (WINDOW_SIZE_FIELD.match(fieldName, parser.getDeprecationHandler())) {
windowSize = parser.intValue(); windowSize = parser.intValue();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "rescore doesn't support [" + fieldName + "]"); throw new ParsingException(parser.getTokenLocation(), "rescore doesn't support [" + fieldName + "]");

View File

@ -475,10 +475,10 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
fieldName = currentName; fieldName = currentName;
} else if (token == XContentParser.Token.START_OBJECT) { } 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"); DEPRECATION_LOGGER.deprecated("[nested_filter] has been deprecated in favour of the [nested] parameter");
nestedFilter = parseInnerQueryBuilder(parser); nestedFilter = parseInnerQueryBuilder(parser);
} else if (NESTED_FIELD.match(currentName)) { } else if (NESTED_FIELD.match(currentName, parser.getDeprecationHandler())) {
nestedSort = NestedSortBuilder.fromXContent(parser); nestedSort = NestedSortBuilder.fromXContent(parser);
} else { } else {
// the json in the format of -> field : { lat : 30, lon : 12 } // the json in the format of -> field : { lat : 30, lon : 12 }
@ -495,17 +495,17 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
geoPoints.add(point); geoPoints.add(point);
} }
} else if (token.isValue()) { } else if (token.isValue()) {
if (ORDER_FIELD.match(currentName)) { if (ORDER_FIELD.match(currentName, parser.getDeprecationHandler())) {
order = SortOrder.fromString(parser.text()); order = SortOrder.fromString(parser.text());
} else if (UNIT_FIELD.match(currentName)) { } else if (UNIT_FIELD.match(currentName, parser.getDeprecationHandler())) {
unit = DistanceUnit.fromString(parser.text()); 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()); 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()); validation = GeoValidationMethod.fromString(parser.text());
} else if (SORTMODE_FIELD.match(currentName)) { } else if (SORTMODE_FIELD.match(currentName, parser.getDeprecationHandler())) {
sortMode = SortMode.fromString(parser.text()); 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"); DEPRECATION_LOGGER.deprecated("[nested_path] has been deprecated in favour of the [nested] parameter");
nestedPath = parser.text(); nestedPath = parser.text();
} else if (token == Token.VALUE_STRING){ } else if (token == Token.VALUE_STRING){

View File

@ -151,7 +151,7 @@ public class SuggestBuilder implements Writeable, ToXContentObject {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName(); fieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (GLOBAL_TEXT_FIELD.match(fieldName)) { if (GLOBAL_TEXT_FIELD.match(fieldName, parser.getDeprecationHandler())) {
suggestBuilder.setGlobalText(parser.text()); suggestBuilder.setGlobalText(parser.text());
} else { } else {
throw new IllegalArgumentException("[suggest] does not support [" + fieldName + "]"); throw new IllegalArgumentException("[suggest] does not support [" + fieldName + "]");

View File

@ -265,11 +265,11 @@ public abstract class SuggestionBuilder<T extends SuggestionBuilder<T>> implemen
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (TEXT_FIELD.match(currentFieldName)) { if (TEXT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
suggestText = parser.text(); suggestText = parser.text();
} else if (PREFIX_FIELD.match(currentFieldName)) { } else if (PREFIX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
prefix = parser.text(); prefix = parser.text();
} else if (REGEX_FIELD.match(currentFieldName)) { } else if (REGEX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
regex = parser.text(); regex = parser.text();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), "suggestion does not support [" + currentFieldName + "]"); throw new ParsingException(parser.getTokenLocation(), "suggestion does not support [" + currentFieldName + "]");

View File

@ -110,7 +110,7 @@ public final class Laplace extends SmoothingModel {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName(); fieldName = parser.currentName();
} }
if (token.isValue() && ALPHA_FIELD.match(fieldName)) { if (token.isValue() && ALPHA_FIELD.match(fieldName, parser.getDeprecationHandler())) {
alpha = parser.doubleValue(); alpha = parser.doubleValue();
} }
} }

View File

@ -139,17 +139,17 @@ public final class LinearInterpolation extends SmoothingModel {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName(); fieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (TRIGRAM_FIELD.match(fieldName)) { if (TRIGRAM_FIELD.match(fieldName, parser.getDeprecationHandler())) {
trigramLambda = parser.doubleValue(); trigramLambda = parser.doubleValue();
if (trigramLambda < 0) { if (trigramLambda < 0) {
throw new IllegalArgumentException("trigram_lambda must be positive"); 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(); bigramLambda = parser.doubleValue();
if (bigramLambda < 0) { if (bigramLambda < 0) {
throw new IllegalArgumentException("bigram_lambda must be positive"); 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(); unigramLambda = parser.doubleValue();
if (unigramLambda < 0) { if (unigramLambda < 0) {
throw new IllegalArgumentException("unigram_lambda must be positive"); throw new IllegalArgumentException("unigram_lambda must be positive");

View File

@ -500,34 +500,34 @@ public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionB
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName)) { if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.analyzer(parser.text()); tmpSuggestion.analyzer(parser.text());
} else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName)) { } else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
fieldname = parser.text(); fieldname = parser.text();
} else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName)) { } else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.size(parser.intValue()); tmpSuggestion.size(parser.intValue());
} else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName)) { } else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.shardSize(parser.intValue()); 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()); tmpSuggestion.realWordErrorLikelihood(parser.floatValue());
} else if (PhraseSuggestionBuilder.CONFIDENCE_FIELD.match(currentFieldName)) { } else if (PhraseSuggestionBuilder.CONFIDENCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.confidence(parser.floatValue()); tmpSuggestion.confidence(parser.floatValue());
} else if (PhraseSuggestionBuilder.SEPARATOR_FIELD.match(currentFieldName)) { } else if (PhraseSuggestionBuilder.SEPARATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.separator(parser.text()); tmpSuggestion.separator(parser.text());
} else if (PhraseSuggestionBuilder.MAXERRORS_FIELD.match(currentFieldName)) { } else if (PhraseSuggestionBuilder.MAXERRORS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.maxErrors(parser.floatValue()); tmpSuggestion.maxErrors(parser.floatValue());
} else if (PhraseSuggestionBuilder.GRAMSIZE_FIELD.match(currentFieldName)) { } else if (PhraseSuggestionBuilder.GRAMSIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.gramSize(parser.intValue()); 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()); 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()); tmpSuggestion.tokenLimit(parser.intValue());
} else { } else {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),
"suggester[phrase] doesn't support field [" + currentFieldName + "]"); "suggester[phrase] doesn't support field [" + currentFieldName + "]");
} }
} else if (token == Token.START_ARRAY) { } 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 // for now we only have a single type of generators
while ((token = parser.nextToken()) == Token.START_OBJECT) { while ((token = parser.nextToken()) == Token.START_OBJECT) {
tmpSuggestion.addCandidateGenerator(DirectCandidateGeneratorBuilder.PARSER.apply(parser, null)); tmpSuggestion.addCandidateGenerator(DirectCandidateGeneratorBuilder.PARSER.apply(parser, null));
@ -537,19 +537,19 @@ public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionB
"suggester[phrase] doesn't support array field [" + currentFieldName + "]"); "suggester[phrase] doesn't support array field [" + currentFieldName + "]");
} }
} else if (token == Token.START_OBJECT) { } else if (token == Token.START_OBJECT) {
if (PhraseSuggestionBuilder.SMOOTHING_MODEL_FIELD.match(currentFieldName)) { if (PhraseSuggestionBuilder.SMOOTHING_MODEL_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
ensureNoSmoothing(tmpSuggestion); ensureNoSmoothing(tmpSuggestion);
tmpSuggestion.smoothingModel(SmoothingModel.fromXContent(parser)); 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 preTag = null;
String postTag = null; String postTag = null;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (PhraseSuggestionBuilder.PRE_TAG_FIELD.match(currentFieldName)) { if (PhraseSuggestionBuilder.PRE_TAG_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
preTag = parser.text(); preTag = parser.text();
} else if (PhraseSuggestionBuilder.POST_TAG_FIELD.match(currentFieldName)) { } else if (PhraseSuggestionBuilder.POST_TAG_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
postTag = parser.text(); postTag = parser.text();
} else { } else {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),
@ -558,11 +558,11 @@ public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionB
} }
} }
tmpSuggestion.highlight(preTag, postTag); 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) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); 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) { if (tmpSuggestion.collateQuery() != null) {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),
"suggester[phrase][collate] query already set, doesn't support additional [" "suggester[phrase][collate] query already set, doesn't support additional ["
@ -570,9 +570,9 @@ public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionB
} }
Script template = Script.parse(parser, Script.DEFAULT_TEMPLATE_LANG); Script template = Script.parse(parser, Script.DEFAULT_TEMPLATE_LANG);
tmpSuggestion.collateQuery(template); 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()); 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()) { if (parser.isBooleanValue()) {
tmpSuggestion.collatePrune(parser.booleanValue()); tmpSuggestion.collatePrune(parser.booleanValue());
} else { } else {

View File

@ -72,11 +72,11 @@ public abstract class SmoothingModel implements NamedWriteable, ToXContentFragme
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName(); fieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) { } 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); model = LinearInterpolation.fromXContent(parser);
} else if (Laplace.PARSE_FIELD.match(fieldName)) { } else if (Laplace.PARSE_FIELD.match(fieldName, parser.getDeprecationHandler())) {
model = Laplace.fromXContent(parser); model = Laplace.fromXContent(parser);
} else if (StupidBackoff.PARSE_FIELD.match(fieldName)) { } else if (StupidBackoff.PARSE_FIELD.match(fieldName, parser.getDeprecationHandler())) {
model = StupidBackoff.fromXContent(parser); model = StupidBackoff.fromXContent(parser);
} else { } else {
throw new IllegalArgumentException("suggester[phrase] doesn't support object field [" + fieldName + "]"); throw new IllegalArgumentException("suggester[phrase] doesn't support object field [" + fieldName + "]");

View File

@ -113,7 +113,7 @@ public final class StupidBackoff extends SmoothingModel {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName(); fieldName = parser.currentName();
} }
if (token.isValue() && DISCOUNT_FIELD.match(fieldName)) { if (token.isValue() && DISCOUNT_FIELD.match(fieldName, parser.getDeprecationHandler())) {
discount = parser.doubleValue(); discount = parser.doubleValue();
} }
} }

View File

@ -396,33 +396,33 @@ public class TermSuggestionBuilder extends SuggestionBuilder<TermSuggestionBuild
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName)) { if (SuggestionBuilder.ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.analyzer(parser.text()); tmpSuggestion.analyzer(parser.text());
} else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName)) { } else if (SuggestionBuilder.FIELDNAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
fieldname = parser.text(); fieldname = parser.text();
} else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName)) { } else if (SuggestionBuilder.SIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.size(parser.intValue()); tmpSuggestion.size(parser.intValue());
} else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName)) { } else if (SuggestionBuilder.SHARDSIZE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.shardSize(parser.intValue()); tmpSuggestion.shardSize(parser.intValue());
} else if (SUGGESTMODE_FIELD.match(currentFieldName)) { } else if (SUGGESTMODE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.suggestMode(SuggestMode.resolve(parser.text())); tmpSuggestion.suggestMode(SuggestMode.resolve(parser.text()));
} else if (ACCURACY_FIELD.match(currentFieldName)) { } else if (ACCURACY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.accuracy(parser.floatValue()); tmpSuggestion.accuracy(parser.floatValue());
} else if (SORT_FIELD.match(currentFieldName)) { } else if (SORT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.sort(SortBy.resolve(parser.text())); 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())); 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()); tmpSuggestion.maxEdits(parser.intValue());
} else if (MAX_INSPECTIONS_FIELD.match(currentFieldName)) { } else if (MAX_INSPECTIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.maxInspections(parser.intValue()); 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()); tmpSuggestion.maxTermFreq(parser.floatValue());
} else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) { } else if (PREFIX_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
tmpSuggestion.prefixLength(parser.intValue()); 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()); 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()); tmpSuggestion.minDocFreq(parser.floatValue());
} else { } else {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),