From 6bca790a80abb56c4a2934f02852a7524cad98e7 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Thu, 8 Feb 2018 13:23:26 -0700 Subject: [PATCH] Remove all instances of the deprecated `ParseField.match` method This removes all the server references to the deprecated `ParseField.match` method in favor of the method that passes in the deprecation logger. Relates to #28504 --- .../org/elasticsearch/common/ParseField.java | 17 ----- .../common/xcontent/XContentHelper.java | 2 +- .../index/query/BoolQueryBuilder.java | 10 +-- .../index/query/BoostingQueryBuilder.java | 10 +-- .../index/query/CommonTermsQueryBuilder.java | 24 +++--- .../query/ConstantScoreQueryBuilder.java | 6 +- .../index/query/DisMaxQueryBuilder.java | 10 +-- .../index/query/ExistsQueryBuilder.java | 10 +-- .../query/FieldMaskingSpanQueryBuilder.java | 8 +- .../index/query/FuzzyQueryBuilder.java | 22 +++--- .../query/GeoBoundingBoxQueryBuilder.java | 28 +++---- .../index/query/GeoDistanceQueryBuilder.java | 14 ++-- .../index/query/GeoPolygonQueryBuilder.java | 6 +- .../index/query/GeoShapeQueryBuilder.java | 22 +++--- .../index/query/MatchNoneQueryBuilder.java | 4 +- .../query/MatchPhrasePrefixQueryBuilder.java | 12 +-- .../index/query/MatchPhraseQueryBuilder.java | 10 +-- .../index/query/MatchQueryBuilder.java | 33 ++++---- .../index/query/MoreLikeThisQueryBuilder.java | 56 +++++++------- .../index/query/MultiMatchQueryBuilder.java | 52 ++++++------- .../index/query/NestedQueryBuilder.java | 14 ++-- .../index/query/PrefixQueryBuilder.java | 11 +-- .../index/query/QueryStringQueryBuilder.java | 75 ++++++++++--------- .../index/query/RangeQueryBuilder.java | 26 +++---- .../index/query/RegexpQueryBuilder.java | 17 +++-- .../index/query/ScriptQueryBuilder.java | 8 +- .../index/query/SimpleQueryStringBuilder.java | 36 ++++----- .../query/SpanContainingQueryBuilder.java | 8 +- .../index/query/SpanFirstQueryBuilder.java | 8 +- .../query/SpanMultiTermQueryBuilder.java | 6 +- .../index/query/SpanNearQueryBuilder.java | 10 +-- .../index/query/SpanNotQueryBuilder.java | 14 ++-- .../index/query/SpanOrQueryBuilder.java | 6 +- .../index/query/SpanTermQueryBuilder.java | 8 +- .../index/query/SpanWithinQueryBuilder.java | 8 +- .../index/query/TermQueryBuilder.java | 8 +- .../index/query/TermsQueryBuilder.java | 4 +- .../index/query/TermsSetQueryBuilder.java | 10 +-- .../index/query/TypeQueryBuilder.java | 8 +- .../index/query/WildcardQueryBuilder.java | 13 ++-- .../index/query/WrapperQueryBuilder.java | 2 +- .../functionscore/DecayFunctionParser.java | 2 +- .../FunctionScoreQueryBuilder.java | 22 +++--- .../ScriptScoreFunctionBuilder.java | 2 +- .../index/query/support/QueryParsers.java | 20 ++--- .../BlobStoreIndexShardSnapshot.java | 14 ++-- .../BlobStoreIndexShardSnapshots.java | 6 +- 47 files changed, 358 insertions(+), 364 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/ParseField.java b/server/src/main/java/org/elasticsearch/common/ParseField.java index 2f85f2dc78b9c..fe5311c7d1cbe 100644 --- a/server/src/main/java/org/elasticsearch/common/ParseField.java +++ b/server/src/main/java/org/elasticsearch/common/ParseField.java @@ -98,23 +98,6 @@ public ParseField withAllDeprecated(String allReplacedWith) { return parseField; } - /** - * Does {@code fieldName} match this field? Uses {@link LoggingDeprecationHandler} - * to prevent us from having to touch every call to {@code match} in the change - * that introduced {@linkplain LoggingDeprecationHandler}. In a followup this will - * be removed. - * @param fieldName - * the field name to match against this {@link ParseField} - * @return true if fieldName matches any of the acceptable - * names for this {@link ParseField}. - * @deprecated Use {@link #match(String, DeprecationHandler)} with - * {@link XContentParser#getDeprecationHandler()} instead. - */ - @Deprecated - public boolean match(String fieldName) { - return match(fieldName, LoggingDeprecationHandler.INSTANCE); - } - /** * Does {@code fieldName} match this field? * @param fieldName diff --git a/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java b/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java index 76d8aa15f870b..eee71e2a4b988 100644 --- a/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java +++ b/server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java @@ -51,7 +51,7 @@ public static XContentParser createParser(NamedXContentRegistry xContentRegistry compressedInput = new BufferedInputStream(compressedInput); } final XContentType contentType = XContentFactory.xContentType(compressedInput); - return XContentFactory.xContent(contentType).createParser(xContentRegistry, compressedInput); + return XContentFactory.xContent(contentType).createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, compressedInput); } else { return XContentFactory.xContent(bytes).createParser(xContentRegistry, bytes.streamInput()); } diff --git a/server/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java index ac57c2abd585b..58697d9ada5ac 100644 --- a/server/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java @@ -333,15 +333,15 @@ public static BoolQueryBuilder fromXContent(XContentParser parser) throws IOExce } } } else if (token.isValue()) { - if (DISABLE_COORD_FIELD.match(currentFieldName)) { + if (DISABLE_COORD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore - } else if (MINIMUM_SHOULD_MATCH.match(currentFieldName)) { + } else if (MINIMUM_SHOULD_MATCH.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatch = parser.textOrNull(); - } else if (BOOST_FIELD.match(currentFieldName)) { + } else if (BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (ADJUST_PURE_NEGATIVE.match(currentFieldName)) { + } else if (ADJUST_PURE_NEGATIVE.match(currentFieldName, parser.getDeprecationHandler())) { adjustPureNegative = parser.booleanValue(); - } else if (NAME_FIELD.match(currentFieldName)) { + } else if (NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[bool] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java index 833e3a2ed0db1..35b0d18b1e88c 100644 --- a/server/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java @@ -152,21 +152,21 @@ public static BoostingQueryBuilder fromXContent(XContentParser parser) throws IO if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (POSITIVE_FIELD.match(currentFieldName)) { + if (POSITIVE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { positiveQuery = parseInnerQueryBuilder(parser); positiveQueryFound = true; - } else if (NEGATIVE_FIELD.match(currentFieldName)) { + } else if (NEGATIVE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { negativeQuery = parseInnerQueryBuilder(parser); negativeQueryFound = true; } else { throw new ParsingException(parser.getTokenLocation(), "[boosting] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (NEGATIVE_BOOST_FIELD.match(currentFieldName)) { + if (NEGATIVE_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { negativeBoost = parser.floatValue(); - } else if (NAME_FIELD.match(currentFieldName)) { + } else if (NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (BOOST_FIELD.match(currentFieldName)) { + } else if (BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); } else { throw new ParsingException(parser.getTokenLocation(), "[boosting] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java index dc7c3d92e924c..c0c08e654807f 100644 --- a/server/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java @@ -271,15 +271,15 @@ public static CommonTermsQueryBuilder fromXContent(XContentParser parser) throws if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) { + if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String innerFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { innerFieldName = parser.currentName(); } else if (token.isValue()) { - if (LOW_FREQ_FIELD.match(innerFieldName)) { + if (LOW_FREQ_FIELD.match(innerFieldName, parser.getDeprecationHandler())) { lowFreqMinimumShouldMatch = parser.text(); - } else if (HIGH_FREQ_FIELD.match(innerFieldName)) { + } else if (HIGH_FREQ_FIELD.match(innerFieldName, parser.getDeprecationHandler())) { highFreqMinimumShouldMatch = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[" + CommonTermsQueryBuilder.NAME + @@ -297,23 +297,23 @@ public static CommonTermsQueryBuilder fromXContent(XContentParser parser) throws "] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { text = parser.objectText(); - } else if (ANALYZER_FIELD.match(currentFieldName)) { + } else if (ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzer = parser.text(); - } else if (DISABLE_COORD_FIELD.match(currentFieldName)) { + } else if (DISABLE_COORD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (HIGH_FREQ_OPERATOR_FIELD.match(currentFieldName)) { + } else if (HIGH_FREQ_OPERATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { highFreqOperator = Operator.fromString(parser.text()); - } else if (LOW_FREQ_OPERATOR_FIELD.match(currentFieldName)) { + } else if (LOW_FREQ_OPERATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { lowFreqOperator = Operator.fromString(parser.text()); - } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) { + } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { lowFreqMinimumShouldMatch = parser.text(); - } else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName)) { + } else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { cutoffFrequency = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[" + CommonTermsQueryBuilder.NAME + diff --git a/server/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java index df4e31c5955a9..18330f9cb4d9b 100644 --- a/server/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java @@ -97,7 +97,7 @@ public static ConstantScoreQueryBuilder fromXContent(XContentParser parser) thro if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (INNER_QUERY_FIELD.match(currentFieldName)) { + if (INNER_QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (queryFound) { throw new ParsingException(parser.getTokenLocation(), "[" + ConstantScoreQueryBuilder.NAME + "]" + " accepts only one 'filter' element."); @@ -109,9 +109,9 @@ public static ConstantScoreQueryBuilder fromXContent(XContentParser parser) thro "[constant_score] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java index 516712040897c..0e2a19e2b0754 100644 --- a/server/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java @@ -136,14 +136,14 @@ public static DisMaxQueryBuilder fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (QUERIES_FIELD.match(currentFieldName)) { + if (QUERIES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queriesFound = true; queries.add(parseInnerQueryBuilder(parser)); } else { throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]"); } } else if (token == XContentParser.Token.START_ARRAY) { - if (QUERIES_FIELD.match(currentFieldName)) { + if (QUERIES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queriesFound = true; while (token != XContentParser.Token.END_ARRAY) { queries.add(parseInnerQueryBuilder(parser)); @@ -153,11 +153,11 @@ public static DisMaxQueryBuilder fromXContent(XContentParser parser) throws IOEx throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]"); } } else { - if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (TIE_BREAKER_FIELD.match(currentFieldName)) { + } else if (TIE_BREAKER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tieBreaker = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/ExistsQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/ExistsQueryBuilder.java index 97378e01236fb..280df7cfa6ad8 100644 --- a/server/src/main/java/org/elasticsearch/index/query/ExistsQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/ExistsQueryBuilder.java @@ -99,11 +99,11 @@ public static ExistsQueryBuilder fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (FIELD_FIELD.match(currentFieldName)) { + if (FIELD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fieldPattern = parser.text(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); } else { throw new ParsingException(parser.getTokenLocation(), "[" + ExistsQueryBuilder.NAME + @@ -131,7 +131,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException { } public static Query newFilter(QueryShardContext context, String fieldPattern) { - + final FieldNamesFieldMapper.FieldNamesFieldType fieldNamesFieldType = (FieldNamesFieldMapper.FieldNamesFieldType) context .getMapperService().fullName(FieldNamesFieldMapper.NAME); if (fieldNamesFieldType == null) { @@ -165,7 +165,7 @@ public static Query newFilter(QueryShardContext context, String fieldPattern) { } private static Query newLegacyExistsQuery(Collection fields) { - // We create TermsQuery directly here rather than using FieldNamesFieldType.termsQuery() + // We create TermsQuery directly here rather than using FieldNamesFieldType.termsQuery() // so we don't end up with deprecation warnings if (fields.size() == 1) { Query filter = new TermQuery(new Term(FieldNamesFieldMapper.NAME, fields.iterator().next())); diff --git a/server/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java index 9fd037f561033..9190d4de14aec 100644 --- a/server/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java @@ -113,7 +113,7 @@ public static FieldMaskingSpanQueryBuilder fromXContent(XContentParser parser) t if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "[field_masking_span] query must be of type span query"); @@ -124,11 +124,11 @@ public static FieldMaskingSpanQueryBuilder fromXContent(XContentParser parser) t + currentFieldName + "]"); } } else { - if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (FIELD_FIELD.match(currentFieldName)) { + } else if (FIELD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { field = parser.text(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java index ba6b4dd0450d6..91843ffbd3c9d 100644 --- a/server/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.common.unit.Fuzziness; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.MappedFieldType; @@ -272,23 +273,23 @@ public static FuzzyQueryBuilder fromXContent(XContentParser parser) throws IOExc if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (TERM_FIELD.match(currentFieldName)) { + if (TERM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectBytes(); - } else if (VALUE_FIELD.match(currentFieldName)) { + } else if (VALUE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectBytes(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (Fuzziness.FIELD.match(currentFieldName)) { + } else if (Fuzziness.FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzziness = Fuzziness.parse(parser); - } else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) { + } else if (PREFIX_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { prefixLength = parser.intValue(); - } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) { + } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxExpansions = parser.intValue(); - } else if (TRANSPOSITIONS_FIELD.match(currentFieldName)) { + } else if (TRANSPOSITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { transpositions = parser.booleanValue(); - } else if (REWRITE_FIELD.match(currentFieldName)) { + } else if (REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { rewrite = parser.textOrNull(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -336,7 +337,8 @@ protected Query doToQuery(QueryShardContext context) throws IOException { query = new FuzzyQuery(new Term(fieldName, BytesRefs.toBytesRef(value)), maxEdits, prefixLength, maxExpansions, transpositions); } if (query instanceof MultiTermQuery) { - MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(rewrite, null); + MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(rewrite, null, + LoggingDeprecationHandler.INSTANCE); QueryParsers.setRewriteMethod((MultiTermQuery) query, rewriteMethod); } return query; diff --git a/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java index 47dcbaa351454..3fea896342270 100644 --- a/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java @@ -403,15 +403,15 @@ public static GeoBoundingBoxQueryBuilder fromXContent(XContentParser parser) thr throw new ElasticsearchParseException("failed to parse [{}] query. [{}]", NAME, e.getMessage()); } } else if (token.isValue()) { - if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (VALIDATION_METHOD_FIELD.match(currentFieldName)) { + } else if (VALIDATION_METHOD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { validationMethod = GeoValidationMethod.fromString(parser.text()); - } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) { + } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ignoreUnmapped = parser.booleanValue(); - } else if (TYPE_FIELD.match(currentFieldName)) { + } else if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { type = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "failed to parse [{}] query. unexpected field [{}]", @@ -479,30 +479,30 @@ public static Rectangle parseBoundingBox(XContentParser parser) throws IOExcepti if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); token = parser.nextToken(); - if (WKT_FIELD.match(currentFieldName)) { + if (WKT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { envelope = (EnvelopeBuilder)(GeoWKTParser.parseExpectedType(parser, GeoShapeType.ENVELOPE)); - } else if (TOP_FIELD.match(currentFieldName)) { + } else if (TOP_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { top = parser.doubleValue(); - } else if (BOTTOM_FIELD.match(currentFieldName)) { + } else if (BOTTOM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { bottom = parser.doubleValue(); - } else if (LEFT_FIELD.match(currentFieldName)) { + } else if (LEFT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { left = parser.doubleValue(); - } else if (RIGHT_FIELD.match(currentFieldName)) { + } else if (RIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { right = parser.doubleValue(); } else { - if (TOP_LEFT_FIELD.match(currentFieldName)) { + if (TOP_LEFT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); top = sparse.getLat(); left = sparse.getLon(); - } else if (BOTTOM_RIGHT_FIELD.match(currentFieldName)) { + } else if (BOTTOM_RIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); bottom = sparse.getLat(); right = sparse.getLon(); - } else if (TOP_RIGHT_FIELD.match(currentFieldName)) { + } else if (TOP_RIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); top = sparse.getLat(); right = sparse.getLon(); - } else if (BOTTOM_LEFT_FIELD.match(currentFieldName)) { + } else if (BOTTOM_LEFT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); bottom = sparse.getLat(); left = sparse.getLon(); diff --git a/server/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java index a6ef5fbd69572..5db7516437314 100644 --- a/server/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java @@ -311,15 +311,15 @@ public static GeoDistanceQueryBuilder fromXContent(XContentParser parser) throws } } } else if (token.isValue()) { - if (DISTANCE_FIELD.match(currentFieldName)) { + if (DISTANCE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (token == XContentParser.Token.VALUE_STRING) { vDistance = parser.text(); // a String } else { vDistance = parser.numberValue(); // a Number } - } else if (UNIT_FIELD.match(currentFieldName)) { + } else if (UNIT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { unit = DistanceUnit.fromString(parser.text()); - } else if (DISTANCE_TYPE_FIELD.match(currentFieldName)) { + } else if (DISTANCE_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { geoDistance = GeoDistance.fromString(parser.text()); } else if (currentFieldName.endsWith(".lat")) { point.resetLat(parser.doubleValue()); @@ -327,13 +327,13 @@ public static GeoDistanceQueryBuilder fromXContent(XContentParser parser) throws } else if (currentFieldName.endsWith(".lon")) { point.resetLon(parser.doubleValue()); fieldName = currentFieldName.substring(0, currentFieldName.length() - ".lon".length()); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) { + } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ignoreUnmapped = parser.booleanValue(); - } else if (VALIDATION_METHOD_FIELD.match(currentFieldName)) { + } else if (VALIDATION_METHOD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { validationMethod = GeoValidationMethod.fromString(parser.text()); } else { if (fieldName == null) { diff --git a/server/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java index 45e71231ab6d7..34c29ab0f1890 100644 --- a/server/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java @@ -243,7 +243,7 @@ public static GeoPolygonQueryBuilder fromXContent(XContentParser parser) throws if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_ARRAY) { - if (POINTS_FIELD.match(currentFieldName)) { + if (POINTS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { shell = new ArrayList<>(); while ((token = parser.nextToken()) != Token.END_ARRAY) { shell.add(GeoUtils.parseGeoPoint(parser)); @@ -262,9 +262,9 @@ public static GeoPolygonQueryBuilder fromXContent(XContentParser parser) throws queryName = parser.text(); } else if ("boost".equals(currentFieldName)) { boost = parser.floatValue(); - } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) { + } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ignoreUnmapped = parser.booleanValue(); - } else if (VALIDATION_METHOD.match(currentFieldName)) { + } else if (VALIDATION_METHOD.match(currentFieldName, parser.getDeprecationHandler())) { validationMethod = GeoValidationMethod.fromString(parser.text()); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java index 5fb9776946326..d3509f475d73c 100644 --- a/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java @@ -515,31 +515,31 @@ public static GeoShapeQueryBuilder fromXContent(XContentParser parser) throws IO if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); token = parser.nextToken(); - if (SHAPE_FIELD.match(currentFieldName)) { + if (SHAPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { shape = ShapeParser.parse(parser); - } else if (STRATEGY_FIELD.match(currentFieldName)) { + } else if (STRATEGY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String strategyName = parser.text(); strategy = SpatialStrategy.fromString(strategyName); if (strategy == null) { throw new ParsingException(parser.getTokenLocation(), "Unknown strategy [" + strategyName + " ]"); } - } else if (RELATION_FIELD.match(currentFieldName)) { + } else if (RELATION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { shapeRelation = ShapeRelation.getRelationByName(parser.text()); if (shapeRelation == null) { throw new ParsingException(parser.getTokenLocation(), "Unknown shape operation [" + parser.text() + " ]"); } - } else if (INDEXED_SHAPE_FIELD.match(currentFieldName)) { + } else if (INDEXED_SHAPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (SHAPE_ID_FIELD.match(currentFieldName)) { + if (SHAPE_ID_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { id = parser.text(); - } else if (SHAPE_TYPE_FIELD.match(currentFieldName)) { + } else if (SHAPE_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { type = parser.text(); - } else if (SHAPE_INDEX_FIELD.match(currentFieldName)) { + } else if (SHAPE_INDEX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { index = parser.text(); - } else if (SHAPE_PATH_FIELD.match(currentFieldName)) { + } else if (SHAPE_PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { shapePath = parser.text(); } } else { @@ -554,11 +554,11 @@ public static GeoShapeQueryBuilder fromXContent(XContentParser parser) throws IO } } } else if (token.isValue()) { - if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) { + } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ignoreUnmapped = parser.booleanValue(); } else { throw new ParsingException(parser.getTokenLocation(), "[" + GeoShapeQueryBuilder.NAME + diff --git a/server/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java index 5049cf5a0e1da..dccc1a5bc086a 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java @@ -66,9 +66,9 @@ public static MatchNoneQueryBuilder fromXContent(XContentParser parser) throws I if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); } else { throw new ParsingException(parser.getTokenLocation(), "["+MatchNoneQueryBuilder.NAME + diff --git a/server/src/main/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilder.java index 28a77c0566756..0e90ba5ae575b 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilder.java @@ -211,17 +211,17 @@ public static MatchPhrasePrefixQueryBuilder fromXContent(XContentParser parser) if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (MatchQueryBuilder.QUERY_FIELD.match(currentFieldName)) { + if (MatchQueryBuilder.QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectText(); - } else if (MatchQueryBuilder.ANALYZER_FIELD.match(currentFieldName)) { + } else if (MatchQueryBuilder.ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzer = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (MatchPhraseQueryBuilder.SLOP_FIELD.match(currentFieldName)) { + } else if (MatchPhraseQueryBuilder.SLOP_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { slop = parser.intValue(); - } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) { + } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxExpansion = parser.intValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java index 1bdab8d78a81d..03a1f78289409 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java @@ -182,15 +182,15 @@ public static MatchPhraseQueryBuilder fromXContent(XContentParser parser) throws if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (MatchQueryBuilder.QUERY_FIELD.match(currentFieldName)) { + if (MatchQueryBuilder.QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectText(); - } else if (MatchQueryBuilder.ANALYZER_FIELD.match(currentFieldName)) { + } else if (MatchQueryBuilder.ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzer = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (SLOP_FIELD.match(currentFieldName)) { + } else if (SLOP_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { slop = parser.intValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/MatchQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MatchQueryBuilder.java index cc19603ea64d8..3895aeab0f3da 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MatchQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MatchQueryBuilder.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.unit.Fuzziness; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.query.support.QueryParsers; @@ -412,7 +413,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException { matchQuery.setFuzzyPrefixLength(prefixLength); matchQuery.setMaxExpansions(maxExpansions); matchQuery.setTranspositions(fuzzyTranspositions); - matchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null)); + matchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null, LoggingDeprecationHandler.INSTANCE)); matchQuery.setLenient(lenient); matchQuery.setCommonTermsCutoff(cutoffFrequency); matchQuery.setZeroTermsQuery(zeroTermsQuery); @@ -481,31 +482,31 @@ public static MatchQueryBuilder fromXContent(XContentParser parser) throws IOExc if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectText(); - } else if (ANALYZER_FIELD.match(currentFieldName)) { + } else if (ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzer = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (Fuzziness.FIELD.match(currentFieldName)) { + } else if (Fuzziness.FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzziness = Fuzziness.parse(parser); - } else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) { + } else if (PREFIX_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { prefixLength = parser.intValue(); - } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) { + } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxExpansion = parser.intValue(); - } else if (OPERATOR_FIELD.match(currentFieldName)) { + } else if (OPERATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { operator = Operator.fromString(parser.text()); - } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) { + } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatch = parser.textOrNull(); - } else if (FUZZY_REWRITE_FIELD.match(currentFieldName)) { + } else if (FUZZY_REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyRewrite = parser.textOrNull(); - } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName)) { + } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyTranspositions = parser.booleanValue(); - } else if (LENIENT_FIELD.match(currentFieldName)) { + } else if (LENIENT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { lenient = parser.booleanValue(); - } else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName)) { + } else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { cutOffFrequency = parser.floatValue(); - } else if (ZERO_TERMS_QUERY_FIELD.match(currentFieldName)) { + } else if (ZERO_TERMS_QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String zeroTermsDocs = parser.text(); if ("none".equalsIgnoreCase(zeroTermsDocs)) { zeroTermsQuery = MatchQuery.ZeroTermsQuery.NONE; @@ -515,9 +516,9 @@ public static MatchQueryBuilder fromXContent(XContentParser parser) throws IOExc throw new ParsingException(parser.getTokenLocation(), "Unsupported zero_terms_docs value [" + zeroTermsDocs + "]"); } - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName)) { + } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName, parser.getDeprecationHandler())) { autoGenerateSynonymsPhraseQuery = parser.booleanValue(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java index 24a4eef9802d5..a94c2dae283a5 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java @@ -366,16 +366,16 @@ public static Item parse(XContentParser parser, Item item) throws IOException { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (currentFieldName != null) { - if (INDEX.match(currentFieldName)) { + if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) { item.index = parser.text(); - } else if (TYPE.match(currentFieldName)) { + } else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { item.type = parser.text(); - } else if (ID.match(currentFieldName)) { + } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { item.id = parser.text(); - } else if (DOC.match(currentFieldName)) { + } else if (DOC.match(currentFieldName, parser.getDeprecationHandler())) { item.doc = jsonBuilder().copyCurrentStructure(parser).bytes(); item.xContentType = XContentType.JSON; - } else if (FIELDS.match(currentFieldName)) { + } else if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) { if (token == XContentParser.Token.START_ARRAY) { List fields = new ArrayList<>(); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { @@ -386,13 +386,13 @@ public static Item parse(XContentParser parser, Item item) throws IOException { throw new ElasticsearchParseException( "failed to parse More Like This item. field [fields] must be an array"); } - } else if (PER_FIELD_ANALYZER.match(currentFieldName)) { + } else if (PER_FIELD_ANALYZER.match(currentFieldName, parser.getDeprecationHandler())) { item.perFieldAnalyzer(TermVectorsRequest.readPerFieldAnalyzer(parser.map())); - } else if (ROUTING.match(currentFieldName)) { + } else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) { item.routing = parser.text(); - } else if (VERSION.match(currentFieldName)) { + } else if (VERSION.match(currentFieldName, parser.getDeprecationHandler())) { item.version = parser.longValue(); - } else if (VERSION_TYPE.match(currentFieldName)) { + } else if (VERSION_TYPE.match(currentFieldName, parser.getDeprecationHandler())) { item.versionType = VersionType.fromString(parser.text()); } else { throw new ElasticsearchParseException( @@ -834,31 +834,31 @@ public static MoreLikeThisQueryBuilder fromXContent(XContentParser parser) throw if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (LIKE.match(currentFieldName)) { + if (LIKE.match(currentFieldName, parser.getDeprecationHandler())) { parseLikeField(parser, likeTexts, likeItems); - } else if (UNLIKE.match(currentFieldName)) { + } else if (UNLIKE.match(currentFieldName, parser.getDeprecationHandler())) { parseLikeField(parser, unlikeTexts, unlikeItems); - } else if (MAX_QUERY_TERMS.match(currentFieldName)) { + } else if (MAX_QUERY_TERMS.match(currentFieldName, parser.getDeprecationHandler())) { maxQueryTerms = parser.intValue(); - } else if (MIN_TERM_FREQ.match(currentFieldName)) { + } else if (MIN_TERM_FREQ.match(currentFieldName, parser.getDeprecationHandler())) { minTermFreq =parser.intValue(); - } else if (MIN_DOC_FREQ.match(currentFieldName)) { + } else if (MIN_DOC_FREQ.match(currentFieldName, parser.getDeprecationHandler())) { minDocFreq = parser.intValue(); - } else if (MAX_DOC_FREQ.match(currentFieldName)) { + } else if (MAX_DOC_FREQ.match(currentFieldName, parser.getDeprecationHandler())) { maxDocFreq = parser.intValue(); - } else if (MIN_WORD_LENGTH.match(currentFieldName)) { + } else if (MIN_WORD_LENGTH.match(currentFieldName, parser.getDeprecationHandler())) { minWordLength = parser.intValue(); - } else if (MAX_WORD_LENGTH.match(currentFieldName)) { + } else if (MAX_WORD_LENGTH.match(currentFieldName, parser.getDeprecationHandler())) { maxWordLength = parser.intValue(); - } else if (ANALYZER.match(currentFieldName)) { + } else if (ANALYZER.match(currentFieldName, parser.getDeprecationHandler())) { analyzer = parser.text(); - } else if (MINIMUM_SHOULD_MATCH.match(currentFieldName)) { + } else if (MINIMUM_SHOULD_MATCH.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatch = parser.text(); - } else if (BOOST_TERMS.match(currentFieldName)) { + } else if (BOOST_TERMS.match(currentFieldName, parser.getDeprecationHandler())) { boostTerms = parser.floatValue(); - } else if (INCLUDE.match(currentFieldName)) { + } else if (INCLUDE.match(currentFieldName, parser.getDeprecationHandler())) { include = parser.booleanValue(); - } else if (FAIL_ON_UNSUPPORTED_FIELD.match(currentFieldName)) { + } else if (FAIL_ON_UNSUPPORTED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { failOnUnsupportedField = parser.booleanValue(); } else if ("boost".equals(currentFieldName)) { boost = parser.floatValue(); @@ -868,20 +868,20 @@ public static MoreLikeThisQueryBuilder fromXContent(XContentParser parser) throw throw new ParsingException(parser.getTokenLocation(), "[mlt] query does not support [" + currentFieldName + "]"); } } else if (token == XContentParser.Token.START_ARRAY) { - if (FIELDS.match(currentFieldName)) { + if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) { fields = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { fields.add(parser.text()); } - } else if (LIKE.match(currentFieldName)) { + } else if (LIKE.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { parseLikeField(parser, likeTexts, likeItems); } - } else if (UNLIKE.match(currentFieldName)) { + } else if (UNLIKE.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { parseLikeField(parser, unlikeTexts, unlikeItems); } - } else if (STOP_WORDS.match(currentFieldName)) { + } else if (STOP_WORDS.match(currentFieldName, parser.getDeprecationHandler())) { stopWords = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { stopWords.add(parser.text()); @@ -890,9 +890,9 @@ public static MoreLikeThisQueryBuilder fromXContent(XContentParser parser) throw throw new ParsingException(parser.getTokenLocation(), "[mlt] query does not support [" + currentFieldName + "]"); } } else if (token == XContentParser.Token.START_OBJECT) { - if (LIKE.match(currentFieldName)) { + if (LIKE.match(currentFieldName, parser.getDeprecationHandler())) { parseLikeField(parser, likeTexts, likeItems); - } else if (UNLIKE.match(currentFieldName)) { + } else if (UNLIKE.match(currentFieldName, parser.getDeprecationHandler())) { parseLikeField(parser, unlikeTexts, unlikeItems); } else { throw new ParsingException(parser.getTokenLocation(), "[mlt] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java index 0411b955b6547..e56fd44f5b856 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java @@ -31,6 +31,8 @@ import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.unit.Fuzziness; +import org.elasticsearch.common.xcontent.DeprecationHandler; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.query.support.QueryParsers; @@ -154,11 +156,11 @@ public ParseField parseField() { return parseField; } - public static Type parse(String value) { + public static Type parse(String value, DeprecationHandler deprecationHandler) { MultiMatchQueryBuilder.Type[] values = MultiMatchQueryBuilder.Type.values(); Type type = null; for (MultiMatchQueryBuilder.Type t : values) { - if (t.parseField().match(value)) { + if (t.parseField().match(value, deprecationHandler)) { type = t; break; } @@ -326,7 +328,7 @@ public MultiMatchQueryBuilder type(Object type) { if (type == null) { throw new IllegalArgumentException("[" + NAME + "] requires type to be non-null"); } - this.type = Type.parse(type.toString().toLowerCase(Locale.ROOT)); + this.type = Type.parse(type.toString().toLowerCase(Locale.ROOT), LoggingDeprecationHandler.INSTANCE); return this; } @@ -639,7 +641,7 @@ public static MultiMatchQueryBuilder fromXContent(XContentParser parser) throws while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); - } else if (FIELDS_FIELD.match(currentFieldName)) { + } else if (FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (token == XContentParser.Token.START_ARRAY) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { parseFieldAndBoost(parser, fieldsBoosts); @@ -651,37 +653,37 @@ public static MultiMatchQueryBuilder fromXContent(XContentParser parser) throws "[" + NAME + "] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectText(); - } else if (TYPE_FIELD.match(currentFieldName)) { - type = MultiMatchQueryBuilder.Type.parse(parser.text()); - } else if (ANALYZER_FIELD.match(currentFieldName)) { + } else if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { + type = MultiMatchQueryBuilder.Type.parse(parser.text(), parser.getDeprecationHandler()); + } else if (ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzer = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (SLOP_FIELD.match(currentFieldName)) { + } else if (SLOP_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { slop = parser.intValue(); - } else if (Fuzziness.FIELD.match(currentFieldName)) { + } else if (Fuzziness.FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzziness = Fuzziness.parse(parser); - } else if (PREFIX_LENGTH_FIELD.match(currentFieldName)) { + } else if (PREFIX_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { prefixLength = parser.intValue(); - } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) { + } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxExpansions = parser.intValue(); - } else if (OPERATOR_FIELD.match(currentFieldName)) { + } else if (OPERATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { operator = Operator.fromString(parser.text()); - } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) { + } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatch = parser.textOrNull(); - } else if (FUZZY_REWRITE_FIELD.match(currentFieldName)) { + } else if (FUZZY_REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyRewrite = parser.textOrNull(); - } else if (USE_DIS_MAX_FIELD.match(currentFieldName)) { + } else if (USE_DIS_MAX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { useDisMax = parser.booleanValue(); - } else if (TIE_BREAKER_FIELD.match(currentFieldName)) { + } else if (TIE_BREAKER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tieBreaker = parser.floatValue(); - } else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName)) { + } else if (CUTOFF_FREQUENCY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { cutoffFrequency = parser.floatValue(); - } else if (LENIENT_FIELD.match(currentFieldName)) { + } else if (LENIENT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { lenient = parser.booleanValue(); - } else if (ZERO_TERMS_QUERY_FIELD.match(currentFieldName)) { + } else if (ZERO_TERMS_QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String zeroTermsDocs = parser.text(); if ("none".equalsIgnoreCase(zeroTermsDocs)) { zeroTermsQuery = MatchQuery.ZeroTermsQuery.NONE; @@ -690,11 +692,11 @@ public static MultiMatchQueryBuilder fromXContent(XContentParser parser) throws } else { throw new ParsingException(parser.getTokenLocation(), "Unsupported zero_terms_docs value [" + zeroTermsDocs + "]"); } - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName)) { + } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName, parser.getDeprecationHandler())) { autoGenerateSynonymsPhraseQuery = parser.booleanValue(); - } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName)) { + } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyTranspositions = parser.booleanValue(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -781,7 +783,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException { multiMatchQuery.setMaxExpansions(maxExpansions); multiMatchQuery.setOccur(operator.toBooleanClauseOccur()); if (fuzzyRewrite != null) { - multiMatchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null)); + multiMatchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null, LoggingDeprecationHandler.INSTANCE)); } if (tieBreaker != null) { multiMatchQuery.setTieBreaker(tieBreaker); diff --git a/server/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java index 95e9e3a1869b0..9ebd548cae1f0 100644 --- a/server/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java @@ -192,23 +192,23 @@ public static NestedQueryBuilder fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { query = parseInnerQueryBuilder(parser); - } else if (INNER_HITS_FIELD.match(currentFieldName)) { + } else if (INNER_HITS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { innerHitBuilder = InnerHitBuilder.fromXContent(parser); } else { throw new ParsingException(parser.getTokenLocation(), "[nested] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (PATH_FIELD.match(currentFieldName)) { + if (PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { path = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName)) { + } else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { ignoreUnmapped = parser.booleanValue(); - } else if (SCORE_MODE_FIELD.match(currentFieldName)) { + } else if (SCORE_MODE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { scoreMode = parseScoreMode(parser.text()); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[nested] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java index fcc688d191a36..c1cd99d712a5a 100644 --- a/server/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.BytesRefs; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.MappedFieldType; @@ -135,13 +136,13 @@ public static PrefixQueryBuilder fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else { - if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (PREFIX_FIELD.match(currentFieldName)) { + } else if (PREFIX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.textOrNull(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (REWRITE_FIELD.match(currentFieldName)) { + } else if (REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { rewrite = parser.textOrNull(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -169,7 +170,7 @@ public String getWriteableName() { @Override protected Query doToQuery(QueryShardContext context) throws IOException { - MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null); + MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); diff --git a/server/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java index 154060ec1a5b0..56c49b7f2c1bf 100644 --- a/server/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.unit.Fuzziness; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; @@ -768,7 +769,7 @@ public static QueryStringQueryBuilder fromXContent(XContentParser parser) throws if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_ARRAY) { - if (FIELDS_FIELD.match(currentFieldName)) { + if (FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List fields = new ArrayList<>(); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { fields.add(parser.text()); @@ -779,76 +780,76 @@ public static QueryStringQueryBuilder fromXContent(XContentParser parser) throws "] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryString = parser.text(); - } else if (DEFAULT_FIELD_FIELD.match(currentFieldName)) { + } else if (DEFAULT_FIELD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { defaultField = parser.text(); - } else if (DEFAULT_OPERATOR_FIELD.match(currentFieldName)) { + } else if (DEFAULT_OPERATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { defaultOperator = Operator.fromString(parser.text()); - } else if (ANALYZER_FIELD.match(currentFieldName)) { + } else if (ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzer = parser.text(); - } else if (QUOTE_ANALYZER_FIELD.match(currentFieldName)) { + } else if (QUOTE_ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { quoteAnalyzer = parser.text(); - } else if (ALLOW_LEADING_WILDCARD_FIELD.match(currentFieldName)) { + } else if (ALLOW_LEADING_WILDCARD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { allowLeadingWildcard = parser.booleanValue(); - } else if (MAX_DETERMINIZED_STATES_FIELD.match(currentFieldName)) { + } else if (MAX_DETERMINIZED_STATES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxDeterminizedStates = parser.intValue(); - } else if (ENABLE_POSITION_INCREMENTS_FIELD.match(currentFieldName)) { + } else if (ENABLE_POSITION_INCREMENTS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { enablePositionIncrements = parser.booleanValue(); - } else if (ESCAPE_FIELD.match(currentFieldName)) { + } else if (ESCAPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { escape = parser.booleanValue(); - } else if (FUZZY_PREFIX_LENGTH_FIELD.match(currentFieldName)) { + } else if (FUZZY_PREFIX_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyPrefixLength = parser.intValue(); - } else if (FUZZY_MAX_EXPANSIONS_FIELD.match(currentFieldName)) { + } else if (FUZZY_MAX_EXPANSIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyMaxExpansions = parser.intValue(); - } else if (FUZZY_REWRITE_FIELD.match(currentFieldName)) { + } else if (FUZZY_REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyRewrite = parser.textOrNull(); - } else if (PHRASE_SLOP_FIELD.match(currentFieldName)) { + } else if (PHRASE_SLOP_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { phraseSlop = parser.intValue(); - } else if (Fuzziness.FIELD.match(currentFieldName)) { + } else if (Fuzziness.FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzziness = Fuzziness.parse(parser); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (TYPE_FIELD.match(currentFieldName)) { - type = MultiMatchQueryBuilder.Type.parse(parser.text()); - } else if (TIE_BREAKER_FIELD.match(currentFieldName)) { + } else if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { + type = MultiMatchQueryBuilder.Type.parse(parser.text(), parser.getDeprecationHandler()); + } else if (TIE_BREAKER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { tieBreaker = parser.floatValue(); - } else if (ANALYZE_WILDCARD_FIELD.match(currentFieldName)) { + } else if (ANALYZE_WILDCARD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzeWildcard = parser.booleanValue(); - } else if (REWRITE_FIELD.match(currentFieldName)) { + } else if (REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { rewrite = parser.textOrNull(); - } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) { + } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatch = parser.textOrNull(); - } else if (QUOTE_FIELD_SUFFIX_FIELD.match(currentFieldName)) { + } else if (QUOTE_FIELD_SUFFIX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { quoteFieldSuffix = parser.textOrNull(); - } else if (LENIENT_FIELD.match(currentFieldName)) { + } else if (LENIENT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { lenient = parser.booleanValue(); - } else if (ALL_FIELDS_FIELD.match(currentFieldName)) { + } else if (ALL_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { defaultField = "*"; - } else if (MAX_DETERMINIZED_STATES_FIELD.match(currentFieldName)) { + } else if (MAX_DETERMINIZED_STATES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxDeterminizedStates = parser.intValue(); - } else if (TIME_ZONE_FIELD.match(currentFieldName)) { + } else if (TIME_ZONE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { try { timeZone = parser.text(); } catch (IllegalArgumentException e) { throw new ParsingException(parser.getTokenLocation(), "[" + QueryStringQueryBuilder.NAME + "] time_zone [" + parser.text() + "] is unknown"); } - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName)) { + } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName, parser.getDeprecationHandler())) { autoGenerateSynonymsPhraseQuery = parser.booleanValue(); - } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName)) { + } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyTranspositions = parser.booleanValue(); - } else if (AUTO_GENERATE_PHRASE_QUERIES_FIELD.match(currentFieldName)) { + } else if (AUTO_GENERATE_PHRASE_QUERIES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore, deprecated setting - } else if (LOWERCASE_EXPANDED_TERMS_FIELD.match(currentFieldName)) { + } else if (LOWERCASE_EXPANDED_TERMS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore, deprecated setting - } else if (LOCALE_FIELD.match(currentFieldName)) { + } else if (LOCALE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore, deprecated setting - } else if (USE_DIS_MAX_FIELD.match(currentFieldName)) { + } else if (USE_DIS_MAX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore, deprecated setting - } else if (SPLIT_ON_WHITESPACE.match(currentFieldName)) { + } else if (SPLIT_ON_WHITESPACE.match(currentFieldName, parser.getDeprecationHandler())) { // ignore, deprecated setting } else { throw new ParsingException(parser.getTokenLocation(), "[" + QueryStringQueryBuilder.NAME + @@ -1004,8 +1005,8 @@ protected Query doToQuery(QueryShardContext context) throws IOException { queryParser.setFuzziness(fuzziness); queryParser.setFuzzyPrefixLength(fuzzyPrefixLength); queryParser.setFuzzyMaxExpansions(fuzzyMaxExpansions); - queryParser.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(this.fuzzyRewrite)); - queryParser.setMultiTermRewriteMethod(QueryParsers.parseRewriteMethod(this.rewrite)); + queryParser.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(this.fuzzyRewrite, LoggingDeprecationHandler.INSTANCE)); + queryParser.setMultiTermRewriteMethod(QueryParsers.parseRewriteMethod(this.rewrite, LoggingDeprecationHandler.INSTANCE)); queryParser.setTimeZone(timeZone); queryParser.setMaxDeterminizedStates(maxDeterminizedStates); queryParser.setAutoGenerateMultiTermSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery); diff --git a/server/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java index 14f1e16f39cbf..9cf008e1b1b2e 100644 --- a/server/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java @@ -376,35 +376,35 @@ public static RangeQueryBuilder fromXContent(XContentParser parser) throws IOExc if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else { - if (FROM_FIELD.match(currentFieldName)) { + if (FROM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { from = parser.objectBytes(); - } else if (TO_FIELD.match(currentFieldName)) { + } else if (TO_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { to = parser.objectBytes(); - } else if (INCLUDE_LOWER_FIELD.match(currentFieldName)) { + } else if (INCLUDE_LOWER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { includeLower = parser.booleanValue(); - } else if (INCLUDE_UPPER_FIELD.match(currentFieldName)) { + } else if (INCLUDE_UPPER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { includeUpper = parser.booleanValue(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (GT_FIELD.match(currentFieldName)) { + } else if (GT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { from = parser.objectBytes(); includeLower = false; - } else if (GTE_FIELD.match(currentFieldName)) { + } else if (GTE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { from = parser.objectBytes(); includeLower = true; - } else if (LT_FIELD.match(currentFieldName)) { + } else if (LT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { to = parser.objectBytes(); includeUpper = false; - } else if (LTE_FIELD.match(currentFieldName)) { + } else if (LTE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { to = parser.objectBytes(); includeUpper = true; - } else if (TIME_ZONE_FIELD.match(currentFieldName)) { + } else if (TIME_ZONE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { timeZone = parser.text(); - } else if (FORMAT_FIELD.match(currentFieldName)) { + } else if (FORMAT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { format = parser.text(); - } else if (RELATION_FIELD.match(currentFieldName)) { + } else if (RELATION_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { relation = parser.text(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java index 96290d9291259..7f697eb20e477 100644 --- a/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.BytesRefs; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.MappedFieldType; @@ -195,20 +196,20 @@ public static RegexpQueryBuilder fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else { - if (VALUE_FIELD.match(currentFieldName)) { + if (VALUE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.textOrNull(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (REWRITE_FIELD.match(currentFieldName)) { + } else if (REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { rewrite = parser.textOrNull(); - } else if (FLAGS_FIELD.match(currentFieldName)) { + } else if (FLAGS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String flags = parser.textOrNull(); flagsValue = RegexpFlag.resolveValue(flags); - } else if (MAX_DETERMINIZED_STATES_FIELD.match(currentFieldName)) { + } else if (MAX_DETERMINIZED_STATES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxDeterminizedStates = parser.intValue(); - } else if (FLAGS_VALUE_FIELD.match(currentFieldName)) { + } else if (FLAGS_VALUE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { flagsValue = parser.intValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -238,7 +239,7 @@ public String getWriteableName() { @Override protected Query doToQuery(QueryShardContext context) throws QueryShardException, IOException { - MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null); + MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); diff --git a/server/src/main/java/org/elasticsearch/index/query/ScriptQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/ScriptQueryBuilder.java index 3d217ab36a243..9cae2f3e061da 100644 --- a/server/src/main/java/org/elasticsearch/index/query/ScriptQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/ScriptQueryBuilder.java @@ -96,17 +96,17 @@ public static ScriptQueryBuilder fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), "[script] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), "[script] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java index 3a9a0c3736b93..e51722195399c 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java @@ -539,7 +539,7 @@ public static SimpleQueryStringBuilder fromXContent(XContentParser parser) throw if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_ARRAY) { - if (FIELDS_FIELD.match(currentFieldName)) { + if (FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { List fields = new ArrayList<>(); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { fields.add(parser.text()); @@ -550,15 +550,15 @@ public static SimpleQueryStringBuilder fromXContent(XContentParser parser) throw "] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryBody = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (ANALYZER_FIELD.match(currentFieldName)) { + } else if (ANALYZER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzerName = parser.text(); - } else if (DEFAULT_OPERATOR_FIELD.match(currentFieldName)) { + } else if (DEFAULT_OPERATOR_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { defaultOperator = Operator.fromString(parser.text()); - } else if (FLAGS_FIELD.match(currentFieldName)) { + } else if (FLAGS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (parser.currentToken() != XContentParser.Token.VALUE_NUMBER) { // Possible options are: // ALL, NONE, AND, OR, PREFIX, PHRASE, PRECEDENCE, ESCAPE, WHITESPACE, FUZZY, NEAR, SLOP @@ -569,29 +569,29 @@ public static SimpleQueryStringBuilder fromXContent(XContentParser parser) throw flags = SimpleQueryStringFlag.ALL.value(); } } - } else if (LOCALE_FIELD.match(currentFieldName)) { + } else if (LOCALE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore, deprecated setting - } else if (LOWERCASE_EXPANDED_TERMS_FIELD.match(currentFieldName)) { + } else if (LOWERCASE_EXPANDED_TERMS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // ignore, deprecated setting - } else if (LENIENT_FIELD.match(currentFieldName)) { + } else if (LENIENT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { lenient = parser.booleanValue(); - } else if (ANALYZE_WILDCARD_FIELD.match(currentFieldName)) { + } else if (ANALYZE_WILDCARD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { analyzeWildcard = parser.booleanValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) { + } else if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatch = parser.textOrNull(); - } else if (QUOTE_FIELD_SUFFIX_FIELD.match(currentFieldName)) { + } else if (QUOTE_FIELD_SUFFIX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { quoteFieldSuffix = parser.textOrNull(); - } else if (ALL_FIELDS_FIELD.match(currentFieldName)) { + } else if (ALL_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { // Ignore deprecated option - } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName)) { + } else if (GENERATE_SYNONYMS_PHRASE_QUERY.match(currentFieldName, parser.getDeprecationHandler())) { autoGenerateSynonymsPhraseQuery = parser.booleanValue(); - } else if (FUZZY_PREFIX_LENGTH_FIELD.match(currentFieldName)) { + } else if (FUZZY_PREFIX_LENGTH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyPrefixLenght = parser.intValue(); - } else if (FUZZY_MAX_EXPANSIONS_FIELD.match(currentFieldName)) { + } else if (FUZZY_MAX_EXPANSIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyMaxExpansions = parser.intValue(); - } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName)) { + } else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { fuzzyTranspositions = parser.booleanValue(); } else { throw new ParsingException(parser.getTokenLocation(), "[" + SimpleQueryStringBuilder.NAME + diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanContainingQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanContainingQueryBuilder.java index 264a8c559c16f..2842b84fa1ce1 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanContainingQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanContainingQueryBuilder.java @@ -111,13 +111,13 @@ public static SpanContainingQueryBuilder fromXContent(XContentParser parser) thr if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (BIG_FIELD.match(currentFieldName)) { + if (BIG_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "span_containing [big] must be of type span query"); } big = (SpanQueryBuilder) query; - } else if (LITTLE_FIELD.match(currentFieldName)) { + } else if (LITTLE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "span_containing [little] must be of type span query"); @@ -127,9 +127,9 @@ public static SpanContainingQueryBuilder fromXContent(XContentParser parser) thr throw new ParsingException(parser.getTokenLocation(), "[span_containing] query does not support [" + currentFieldName + "]"); } - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java index 135f4086020e8..376e87424da59 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java @@ -112,7 +112,7 @@ public static SpanFirstQueryBuilder fromXContent(XContentParser parser) throws I if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (MATCH_FIELD.match(currentFieldName)) { + if (MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "spanFirst [match] must be of type span query"); @@ -122,11 +122,11 @@ public static SpanFirstQueryBuilder fromXContent(XContentParser parser) throws I throw new ParsingException(parser.getTokenLocation(), "[span_first] query does not support [" + currentFieldName + "]"); } } else { - if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (END_FIELD.match(currentFieldName)) { + } else if (END_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { end = parser.intValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[span_first] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilder.java index 7b469b3ef4639..4f102b58616f6 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilder.java @@ -91,7 +91,7 @@ public static SpanMultiTermQueryBuilder fromXContent(XContentParser parser) thro if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (MATCH_FIELD.match(currentFieldName)) { + if (MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof MultiTermQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), @@ -102,9 +102,9 @@ public static SpanMultiTermQueryBuilder fromXContent(XContentParser parser) thro throw new ParsingException(parser.getTokenLocation(), "[span_multi] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); } else { throw new ParsingException(parser.getTokenLocation(), "[span_multi] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java index 63c886431b369..7ff181acb9033 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java @@ -159,7 +159,7 @@ public static SpanNearQueryBuilder fromXContent(XContentParser parser) throws IO if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_ARRAY) { - if (CLAUSES_FIELD.match(currentFieldName)) { + if (CLAUSES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { @@ -171,13 +171,13 @@ public static SpanNearQueryBuilder fromXContent(XContentParser parser) throws IO throw new ParsingException(parser.getTokenLocation(), "[span_near] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (IN_ORDER_FIELD.match(currentFieldName)) { + if (IN_ORDER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { inOrder = parser.booleanValue(); - } else if (SLOP_FIELD.match(currentFieldName)) { + } else if (SLOP_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { slop = parser.intValue(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[span_near] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java index ca1d30ccbd6a6..e65310d84a4c7 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java @@ -178,13 +178,13 @@ public static SpanNotQueryBuilder fromXContent(XContentParser parser) throws IOE if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (INCLUDE_FIELD.match(currentFieldName)) { + if (INCLUDE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "spanNot [include] must be of type span query"); } include = (SpanQueryBuilder) query; - } else if (EXCLUDE_FIELD.match(currentFieldName)) { + } else if (EXCLUDE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "spanNot [exclude] must be of type span query"); @@ -194,15 +194,15 @@ public static SpanNotQueryBuilder fromXContent(XContentParser parser) throws IOE throw new ParsingException(parser.getTokenLocation(), "[span_not] query does not support [" + currentFieldName + "]"); } } else { - if (DIST_FIELD.match(currentFieldName)) { + if (DIST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { dist = parser.intValue(); - } else if (PRE_FIELD.match(currentFieldName)) { + } else if (PRE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { pre = parser.intValue(); - } else if (POST_FIELD.match(currentFieldName)) { + } else if (POST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { post = parser.intValue(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[span_not] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java index 2ed46c7f5ee10..3a44a8d2c1598 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java @@ -109,7 +109,7 @@ public static SpanOrQueryBuilder fromXContent(XContentParser parser) throws IOEx if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_ARRAY) { - if (CLAUSES_FIELD.match(currentFieldName)) { + if (CLAUSES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { @@ -121,9 +121,9 @@ public static SpanOrQueryBuilder fromXContent(XContentParser parser) throws IOEx throw new ParsingException(parser.getTokenLocation(), "[span_or] query does not support [" + currentFieldName + "]"); } } else { - if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[span_or] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java index 8c0e56266fbca..f5b286451863f 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java @@ -108,13 +108,13 @@ public static SpanTermQueryBuilder fromXContent(XContentParser parser) throws IO if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else { - if (TERM_FIELD.match(currentFieldName)) { + if (TERM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectBytes(); - } else if (BaseTermQueryBuilder.VALUE_FIELD.match(currentFieldName)) { + } else if (BaseTermQueryBuilder.VALUE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectBytes(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/SpanWithinQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/SpanWithinQueryBuilder.java index 714ad02c18cf0..a454dd0fb521b 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SpanWithinQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/SpanWithinQueryBuilder.java @@ -116,13 +116,13 @@ public static SpanWithinQueryBuilder fromXContent(XContentParser parser) throws if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (BIG_FIELD.match(currentFieldName)) { + if (BIG_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "span_within [big] must be of type span query"); } big = (SpanQueryBuilder) query; - } else if (LITTLE_FIELD.match(currentFieldName)) { + } else if (LITTLE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { QueryBuilder query = parseInnerQueryBuilder(parser); if (query instanceof SpanQueryBuilder == false) { throw new ParsingException(parser.getTokenLocation(), "span_within [little] must be of type span query"); @@ -132,9 +132,9 @@ public static SpanWithinQueryBuilder fromXContent(XContentParser parser) throws throw new ParsingException(parser.getTokenLocation(), "[span_within] query does not support [" + currentFieldName + "]"); } - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[span_within] query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java index 8ee7c699c0071..0df4973329d36 100644 --- a/server/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java @@ -99,13 +99,13 @@ public static TermQueryBuilder fromXContent(XContentParser parser) throws IOExce if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else { - if (TERM_FIELD.match(currentFieldName)) { + if (TERM_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectBytes(); - } else if (VALUE_FIELD.match(currentFieldName)) { + } else if (VALUE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.objectBytes(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java index 478e583b936a6..f235c785cb195 100644 --- a/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java @@ -369,9 +369,9 @@ public static TermsQueryBuilder fromXContent(XContentParser parser) throws IOExc fieldName = currentFieldName; termsLookup = TermsLookup.parseTermsLookup(parser); } else if (token.isValue()) { - if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), diff --git a/server/src/main/java/org/elasticsearch/index/query/TermsSetQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/TermsSetQueryBuilder.java index b704c89819fa8..b8afe967b05ff 100644 --- a/server/src/main/java/org/elasticsearch/index/query/TermsSetQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/TermsSetQueryBuilder.java @@ -170,25 +170,25 @@ public static TermsSetQueryBuilder fromXContent(XContentParser parser) throws IO if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_ARRAY) { - if (TERMS_FIELD.match(currentFieldName)) { + if (TERMS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { values = TermsQueryBuilder.parseValues(parser); } else { throw new ParsingException(parser.getTokenLocation(), "[" + NAME + "] query does not support [" + currentFieldName + "]"); } } else if (token == XContentParser.Token.START_OBJECT) { - if (MINIMUM_SHOULD_MATCH_SCRIPT.match(currentFieldName)) { + if (MINIMUM_SHOULD_MATCH_SCRIPT.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatchScript = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), "[" + NAME + "] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { - if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName)) { + if (MINIMUM_SHOULD_MATCH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { minimumShouldMatchField = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), "[" + NAME + "] query does not support [" diff --git a/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java index d53736a38363d..c6df4f59e7eeb 100644 --- a/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java @@ -90,11 +90,11 @@ public static TypeQueryBuilder fromXContent(XContentParser parser) throws IOExce if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { - if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (VALUE_FIELD.match(currentFieldName)) { + } else if (VALUE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { type = parser.utf8Bytes(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -142,4 +142,4 @@ protected int doHashCode() { protected boolean doEquals(TypeQueryBuilder other) { return Objects.equals(type, other.type); } -} \ No newline at end of file +} diff --git a/server/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java index 8303f8e1e9436..351cddd59004f 100644 --- a/server/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.BytesRefs; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.IndexFieldMapper; @@ -153,15 +154,15 @@ public static WildcardQueryBuilder fromXContent(XContentParser parser) throws IO if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else { - if (WILDCARD_FIELD.match(currentFieldName)) { + if (WILDCARD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.text(); - } else if (VALUE_FIELD.match(currentFieldName)) { + } else if (VALUE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { value = parser.text(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (REWRITE_FIELD.match(currentFieldName)) { + } else if (REWRITE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { rewrite = parser.textOrNull(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); } else { throw new ParsingException(parser.getTokenLocation(), @@ -197,7 +198,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException { } WildcardQuery query = new WildcardQuery(term); - MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(rewrite, null); + MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); QueryParsers.setRewriteMethod(query, rewriteMethod); return query; } diff --git a/server/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java index df765568eae87..50497ce2a9d2a 100644 --- a/server/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java @@ -121,7 +121,7 @@ public static WrapperQueryBuilder fromXContent(XContentParser parser) throws IOE throw new ParsingException(parser.getTokenLocation(), "[wrapper] query malformed"); } String fieldName = parser.currentName(); - if (! QUERY_FIELD.match(fieldName)) { + if (! QUERY_FIELD.match(fieldName, parser.getDeprecationHandler())) { throw new ParsingException(parser.getTokenLocation(), "[wrapper] query malformed, expected `query` but was " + fieldName); } parser.nextToken(); diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java index 6fe41471e2f22..989c52d8fd46e 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java @@ -110,7 +110,7 @@ public DFB fromXContent(XContentParser parser) throws IOException, ParsingExcept XContentBuilder builder = XContentFactory.jsonBuilder(); builder.copyCurrentStructure(parser); functionBytes = builder.bytes(); - } else if (MULTI_VALUE_MODE.match(currentFieldName)) { + } else if (MULTI_VALUE_MODE.match(currentFieldName, parser.getDeprecationHandler())) { multiValueMode = MultiValueMode.fromString(parser.text()); } else { throw new ParsingException(parser.getTokenLocation(), "malformed score function score parameters."); diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java index 437d49ae37f7a..b14fab84130b1 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java @@ -454,7 +454,7 @@ public static FunctionScoreQueryBuilder fromXContent(XContentParser parser) thro if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (QUERY_FIELD.match(currentFieldName)) { + if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (query != null) { throw new ParsingException(parser.getTokenLocation(), "failed to parse [{}] query. [query] is already defined.", NAME); @@ -479,7 +479,7 @@ public static FunctionScoreQueryBuilder fromXContent(XContentParser parser) thro filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(scoreFunction)); } } else if (token == XContentParser.Token.START_ARRAY) { - if (FUNCTIONS_FIELD.match(currentFieldName)) { + if (FUNCTIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (singleFunctionFound) { String errorString = "already found [" + singleFunctionName + "], now encountering [functions]."; handleMisplacedFunctionsDeclaration(parser.getTokenLocation(), errorString); @@ -492,17 +492,17 @@ public static FunctionScoreQueryBuilder fromXContent(XContentParser parser) thro } } else if (token.isValue()) { - if (SCORE_MODE_FIELD.match(currentFieldName)) { + if (SCORE_MODE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { scoreMode = FunctionScoreQuery.ScoreMode.fromString(parser.text()); - } else if (BOOST_MODE_FIELD.match(currentFieldName)) { + } else if (BOOST_MODE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { combineFunction = CombineFunction.fromString(parser.text()); - } else if (MAX_BOOST_FIELD.match(currentFieldName)) { + } else if (MAX_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { maxBoost = parser.floatValue(); - } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { boost = parser.floatValue(); - } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) { + } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { queryName = parser.text(); - } else if (MIN_SCORE_FIELD.match(currentFieldName)) { + } else if (MIN_SCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { minScore = parser.floatValue(); } else { if (singleFunctionFound) { @@ -515,7 +515,7 @@ public static FunctionScoreQueryBuilder fromXContent(XContentParser parser) thro String errorString = "already found [functions] array, now encountering [" + currentFieldName + "]."; handleMisplacedFunctionsDeclaration(parser.getTokenLocation(), errorString); } - if (WEIGHT_FIELD.match(currentFieldName)) { + if (WEIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { filterFunctionBuilders.add( new FunctionScoreQueryBuilder.FilterFunctionBuilder(new WeightBuilder().setWeight(parser.floatValue()))); singleFunctionFound = true; @@ -569,7 +569,7 @@ private static String parseFiltersAndFunctions(XContentParser parser, if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { - if (FILTER_FIELD.match(currentFieldName)) { + if (FILTER_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { filter = parseInnerQueryBuilder(parser); } else { if (scoreFunction != null) { @@ -580,7 +580,7 @@ private static String parseFiltersAndFunctions(XContentParser parser, scoreFunction = parser.namedObject(ScoreFunctionBuilder.class, currentFieldName, null); } } else if (token.isValue()) { - if (WEIGHT_FIELD.match(currentFieldName)) { + if (WEIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { functionWeight = parser.floatValue(); } else { throw new ParsingException(parser.getTokenLocation(), "failed to parse [{}] query. field [{}] is not supported", diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreFunctionBuilder.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreFunctionBuilder.java index 60f3918863969..cc89518154d12 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreFunctionBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/ScriptScoreFunctionBuilder.java @@ -109,7 +109,7 @@ public static ScriptScoreFunctionBuilder fromXContent(XContentParser parser) if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else { - if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) { + if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { script = Script.parse(parser); } else { throw new ParsingException(parser.getTokenLocation(), NAME + " query does not support [" + currentFieldName + "]"); diff --git a/server/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java b/server/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java index 036efa75bdaa3..f880913747307 100644 --- a/server/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java +++ b/server/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java @@ -22,6 +22,7 @@ import org.apache.lucene.search.MultiTermQuery; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.xcontent.DeprecationHandler; public final class QueryParsers { @@ -43,22 +44,23 @@ public static void setRewriteMethod(MultiTermQuery query, @Nullable MultiTermQue query.setRewriteMethod(rewriteMethod); } - public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod) { - return parseRewriteMethod(rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE); + public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod, DeprecationHandler deprecationHandler) { + return parseRewriteMethod(rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE, deprecationHandler); } public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod, - @Nullable MultiTermQuery.RewriteMethod defaultRewriteMethod) { + @Nullable MultiTermQuery.RewriteMethod defaultRewriteMethod, + DeprecationHandler deprecationHandler) { if (rewriteMethod == null) { return defaultRewriteMethod; } - if (CONSTANT_SCORE.match(rewriteMethod)) { + if (CONSTANT_SCORE.match(rewriteMethod, deprecationHandler)) { return MultiTermQuery.CONSTANT_SCORE_REWRITE; } - if (SCORING_BOOLEAN.match(rewriteMethod)) { + if (SCORING_BOOLEAN.match(rewriteMethod, deprecationHandler)) { return MultiTermQuery.SCORING_BOOLEAN_REWRITE; } - if (CONSTANT_SCORE_BOOLEAN.match(rewriteMethod)) { + if (CONSTANT_SCORE_BOOLEAN.match(rewriteMethod, deprecationHandler)) { return MultiTermQuery.CONSTANT_SCORE_BOOLEAN_REWRITE; } @@ -74,13 +76,13 @@ public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String r final int size = Integer.parseInt(rewriteMethod.substring(firstDigit)); String rewriteMethodName = rewriteMethod.substring(0, firstDigit); - if (TOP_TERMS.match(rewriteMethodName)) { + if (TOP_TERMS.match(rewriteMethodName, deprecationHandler)) { return new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(size); } - if (TOP_TERMS_BOOST.match(rewriteMethodName)) { + if (TOP_TERMS_BOOST.match(rewriteMethodName, deprecationHandler)) { return new MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite(size); } - if (TOP_TERMS_BLENDED_FREQS.match(rewriteMethodName)) { + if (TOP_TERMS_BLENDED_FREQS.match(rewriteMethodName, deprecationHandler)) { return new MultiTermQuery.TopTermsBlendedFreqScoringRewrite(size); } } diff --git a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java index b0767a7c512ec..124b538d3facf 100644 --- a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java +++ b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java @@ -516,24 +516,24 @@ public static BlobStoreIndexShardSnapshot fromXContent(XContentParser parser) th String currentFieldName = parser.currentName(); token = parser.nextToken(); if (token.isValue()) { - if (PARSE_NAME.match(currentFieldName)) { + if (PARSE_NAME.match(currentFieldName, parser.getDeprecationHandler())) { snapshot = parser.text(); - } else if (PARSE_INDEX_VERSION.match(currentFieldName)) { + } else if (PARSE_INDEX_VERSION.match(currentFieldName, parser.getDeprecationHandler())) { // The index-version is needed for backward compatibility with v 1.0 indexVersion = parser.longValue(); - } else if (PARSE_START_TIME.match(currentFieldName)) { + } else if (PARSE_START_TIME.match(currentFieldName, parser.getDeprecationHandler())) { startTime = parser.longValue(); - } else if (PARSE_TIME.match(currentFieldName)) { + } else if (PARSE_TIME.match(currentFieldName, parser.getDeprecationHandler())) { time = parser.longValue(); - } else if (PARSE_NUMBER_OF_FILES.match(currentFieldName)) { + } else if (PARSE_NUMBER_OF_FILES.match(currentFieldName, parser.getDeprecationHandler())) { numberOfFiles = parser.intValue(); - } else if (PARSE_TOTAL_SIZE.match(currentFieldName)) { + } else if (PARSE_TOTAL_SIZE.match(currentFieldName, parser.getDeprecationHandler())) { totalSize = parser.longValue(); } else { throw new ElasticsearchParseException("unknown parameter [{}]", currentFieldName); } } else if (token == XContentParser.Token.START_ARRAY) { - if (PARSE_FILES.match(currentFieldName)) { + if (PARSE_FILES.match(currentFieldName, parser.getDeprecationHandler())) { while ((parser.nextToken()) != XContentParser.Token.END_ARRAY) { indexFiles.add(FileInfo.fromXContent(parser)); } diff --git a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java index 7ecf92d3bf11f..d25b1eb04866d 100644 --- a/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java +++ b/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java @@ -243,7 +243,7 @@ public static BlobStoreIndexShardSnapshots fromXContent(XContentParser parser) t String currentFieldName = parser.currentName(); token = parser.nextToken(); if (token == XContentParser.Token.START_ARRAY) { - if (ParseFields.FILES.match(currentFieldName) == false) { + if (ParseFields.FILES.match(currentFieldName, parser.getDeprecationHandler()) == false) { throw new ElasticsearchParseException("unknown array [{}]", currentFieldName); } while (parser.nextToken() != XContentParser.Token.END_ARRAY) { @@ -251,7 +251,7 @@ public static BlobStoreIndexShardSnapshots fromXContent(XContentParser parser) t files.put(fileInfo.name(), fileInfo); } } else if (token == XContentParser.Token.START_OBJECT) { - if (ParseFields.SNAPSHOTS.match(currentFieldName) == false) { + if (ParseFields.SNAPSHOTS.match(currentFieldName, parser.getDeprecationHandler()) == false) { throw new ElasticsearchParseException("unknown object [{}]", currentFieldName); } while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -266,7 +266,7 @@ public static BlobStoreIndexShardSnapshots fromXContent(XContentParser parser) t if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); if (parser.nextToken() == XContentParser.Token.START_ARRAY) { - if (ParseFields.FILES.match(currentFieldName) == false) { + if (ParseFields.FILES.match(currentFieldName, parser.getDeprecationHandler()) == false) { throw new ElasticsearchParseException("unknown array [{}]", currentFieldName); } List fileNames = new ArrayList<>();