diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java b/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java index d5b398c048a..9d1a39d1dac 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java @@ -145,7 +145,7 @@ public class AliasValidator extends AbstractComponent { QueryShardContext context = indexQueryParserService.getShardContext(); try { context.reset(parser); - context.parseContext().parseInnerFilter(); + context.parseContext().parseInnerQueryBuilder().toFilter(context); } finally { context.reset(null); parser.close(); diff --git a/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java index de184df8eb7..3d454e32ec3 100644 --- a/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java @@ -109,10 +109,7 @@ public abstract class AbstractQueryBuilder exte return result; } - //norelease to be made abstract once all query builders override doToQuery providing their own specific implementation. - protected Query doToQuery(QueryShardContext context) throws IOException { - return context.indexQueryParserService().indicesQueriesRegistry().queryParsers().get(getName()).parse(context); - } + protected abstract Query doToQuery(QueryShardContext context) throws IOException; /** * Returns the query name for the query. diff --git a/core/src/main/java/org/elasticsearch/index/query/BaseQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/BaseQueryParser.java deleted file mode 100644 index e732218cac5..00000000000 --- a/core/src/main/java/org/elasticsearch/index/query/BaseQueryParser.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.query; - -import org.apache.lucene.search.Query; - -import java.io.IOException; - -/** - * Class used during the query parsers refactoring. Will be removed once we can parse search requests on the coordinating node. - * All query parsers that have a refactored "fromXContent" method can be changed to extend this instead of {@link BaseQueryParserTemp}. - * Keeps old {@link QueryParser#parse(QueryShardContext)} method as a stub delegating to - * {@link QueryParser#fromXContent(QueryParseContext)} and {@link QueryBuilder#toQuery(QueryShardContext)}} - */ -//norelease needs to be removed once we parse search requests on the coordinating node, as the parse method is not needed anymore at that point. -public abstract class BaseQueryParser> implements QueryParser { - - @Override - public final Query parse(QueryShardContext context) throws IOException { - return fromXContent(context.parseContext()).toQuery(context); - } -} diff --git a/core/src/main/java/org/elasticsearch/index/query/BaseQueryParserTemp.java b/core/src/main/java/org/elasticsearch/index/query/BaseQueryParserTemp.java deleted file mode 100644 index a1e92849918..00000000000 --- a/core/src/main/java/org/elasticsearch/index/query/BaseQueryParserTemp.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.query; - -import org.apache.lucene.search.Query; - -import java.io.IOException; - -/** - * This class with method impl is an intermediate step in the query parsers refactoring. - * Provides a fromXContent default implementation for query parsers that don't have yet a - * specific fromXContent implementation that returns a QueryBuilder. - */ -//norelease to be removed once all queries are moved over to extend BaseQueryParser -public abstract class BaseQueryParserTemp implements QueryParser { - - @Override - public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { - Query query = parse(parseContext.shardContext()); - return new QueryWrappingQueryBuilder(query); - } -} diff --git a/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java index 8c585224661..13b5f509084 100644 --- a/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java @@ -32,7 +32,7 @@ import java.util.List; /** * Parser for bool query */ -public class BoolQueryParser extends BaseQueryParser { +public class BoolQueryParser implements QueryParser { @Inject public BoolQueryParser(Settings settings) { @@ -78,12 +78,12 @@ public class BoolQueryParser extends BaseQueryParser { shouldClauses.add(query); break; case "filter": - query = parseContext.parseInnerFilterToQueryBuilder(); + query = parseContext.parseInnerQueryBuilder(); filterClauses.add(query); break; case "must_not": case "mustNot": - query = parseContext.parseInnerFilterToQueryBuilder(); + query = parseContext.parseInnerQueryBuilder(); mustNotClauses.add(query); break; default: @@ -101,12 +101,12 @@ public class BoolQueryParser extends BaseQueryParser { shouldClauses.add(query); break; case "filter": - query = parseContext.parseInnerFilterToQueryBuilder(); + query = parseContext.parseInnerQueryBuilder(); filterClauses.add(query); break; case "must_not": case "mustNot": - query = parseContext.parseInnerFilterToQueryBuilder(); + query = parseContext.parseInnerQueryBuilder(); mustNotClauses.add(query); break; default: diff --git a/core/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java index ce3b7a05121..81b32dd1635 100644 --- a/core/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -28,7 +27,7 @@ import java.io.IOException; /** * Parser for boosting query */ -public class BoostingQueryParser extends BaseQueryParser { +public class BoostingQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java index 4439ff89893..86de4e31129 100644 --- a/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java @@ -27,7 +27,7 @@ import java.io.IOException; /** * Parser for common terms query */ -public class CommonTermsQueryParser extends BaseQueryParser { +public class CommonTermsQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java index abba9d7745c..8eda81424f2 100644 --- a/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java @@ -29,7 +29,7 @@ import java.io.IOException; /** * Parser for constant_score query */ -public class ConstantScoreQueryParser extends BaseQueryParser { +public class ConstantScoreQueryParser implements QueryParser { private static final ParseField INNER_QUERY_FIELD = new ParseField("filter", "query"); @@ -56,7 +56,7 @@ public class ConstantScoreQueryParser extends BaseQueryParser { +public class DisMaxQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java index ad2382e781a..f0df84f9aa8 100644 --- a/core/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -28,7 +27,7 @@ import java.io.IOException; /** * Parser for exists query */ -public class ExistsQueryParser extends BaseQueryParser { +public class ExistsQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java index 045670d0c61..8ce123b78cf 100644 --- a/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java @@ -21,14 +21,13 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; /** * Parser for field_masking_span query */ -public class FieldMaskingSpanQueryParser extends BaseQueryParser { +public class FieldMaskingSpanQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java index 24acdc6a1f8..340094af7ce 100644 --- a/core/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java @@ -21,14 +21,11 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.query.support.QueryParsers; - import java.io.IOException; -public class FuzzyQueryParser extends BaseQueryParser { +public class FuzzyQueryParser implements QueryParser { private static final ParseField FUZZINESS = Fuzziness.FIELD.withDeprecation("min_similarity"); @@ -38,14 +35,14 @@ public class FuzzyQueryParser extends BaseQueryParser { } @Override - public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { + public FuzzyQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); if (token != XContentParser.Token.FIELD_NAME) { throw new ParsingException(parser.getTokenLocation(), "[fuzzy] query malformed, no field"); } - + String fieldName = parser.currentName(); Object value = null; diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java index d3098480195..638968f93f2 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; -public class GeoBoundingBoxQueryParser extends BaseQueryParser { +public class GeoBoundingBoxQueryParser implements QueryParser { public static final String NAME = "geo_bbox"; diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java index e4171c6dfb5..a2bbba59709 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java @@ -39,7 +39,7 @@ import java.io.IOException; * } * */ -public class GeoDistanceQueryParser extends BaseQueryParser { +public class GeoDistanceQueryParser implements QueryParser { @Override public String[] names() { @@ -47,7 +47,7 @@ public class GeoDistanceQueryParser extends BaseQueryParser { } @Override - public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { + public GeoDistanceQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { XContentParser parser = parseContext.parser(); XContentParser.Token token; diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java index bb209f0795b..203217121ee 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java @@ -37,7 +37,7 @@ import java.io.IOException; * } * */ -public class GeoDistanceRangeQueryParser extends BaseQueryParser { +public class GeoDistanceRangeQueryParser implements QueryParser { public static final ParseField FROM_FIELD = new ParseField("from"); public static final ParseField TO_FIELD = new ParseField("to"); diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java index e87003641bd..a4cb5d757dc 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java @@ -115,7 +115,7 @@ public class GeoPolygonQueryBuilder extends AbstractQueryBuilder */ -public class GeoPolygonQueryParser extends BaseQueryParser { +public class GeoPolygonQueryParser implements QueryParser { public static final ParseField COERCE_FIELD = new ParseField("coerce", "normalize"); public static final ParseField IGNORE_MALFORMED_FIELD = new ParseField("ignore_malformed"); diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java index 3974541c706..e5198952c13 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; -public class GeoShapeQueryParser extends BaseQueryParser { +public class GeoShapeQueryParser implements QueryParser { public static final ParseField SHAPE_FIELD = new ParseField("shape"); public static final ParseField STRATEGY_FIELD = new ParseField("strategy"); diff --git a/core/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java b/core/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java index 396f6cf7eb8..b779d802704 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java @@ -266,7 +266,7 @@ public class GeohashCellQuery { } } - public static class Parser extends BaseQueryParser { + public static class Parser implements QueryParser { @Inject public Parser() { diff --git a/core/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java index ecd41d31bc3..ede48da4550 100644 --- a/core/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java @@ -31,7 +31,7 @@ import java.io.IOException; /** * A query parser for has_child queries. */ -public class HasChildQueryParser extends BaseQueryParser { +public class HasChildQueryParser implements QueryParser { private static final ParseField QUERY_FIELD = new ParseField("query", "filter"); @@ -41,7 +41,7 @@ public class HasChildQueryParser extends BaseQueryParser { } @Override - public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { + public HasChildQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { XContentParser parser = parseContext.parser(); float boost = AbstractQueryBuilder.DEFAULT_BOOST; String childType = null; diff --git a/core/src/main/java/org/elasticsearch/index/query/HasParentQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/HasParentQueryParser.java index a07aa32e14e..39306ed20f5 100644 --- a/core/src/main/java/org/elasticsearch/index/query/HasParentQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/HasParentQueryParser.java @@ -27,7 +27,7 @@ import org.elasticsearch.index.query.support.QueryInnerHits; import java.io.IOException; -public class HasParentQueryParser extends BaseQueryParser { +public class HasParentQueryParser implements QueryParser { private static final HasParentQueryBuilder PROTOTYPE = new HasParentQueryBuilder("", EmptyQueryBuilder.PROTOTYPE); private static final ParseField QUERY_FIELD = new ParseField("query", "filter"); @@ -40,7 +40,7 @@ public class HasParentQueryParser extends BaseQueryParser { } @Override - public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { + public HasParentQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { XContentParser parser = parseContext.parser(); float boost = AbstractQueryBuilder.DEFAULT_BOOST; diff --git a/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java index cd42d85b45d..0ffd31644e5 100644 --- a/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java @@ -30,7 +30,7 @@ import java.util.List; /** * Parser for ids query */ -public class IdsQueryParser extends BaseQueryParser { +public class IdsQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java b/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java index 4c71b3bc613..75ba707cd99 100644 --- a/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java +++ b/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java @@ -225,7 +225,7 @@ public class IndexQueryParserService extends AbstractIndexComponent { QueryShardContext context = cache.get(); context.reset(parser); try { - Query filter = context.parseContext().parseInnerFilter(); + Query filter = context.parseContext().parseInnerQueryBuilder().toFilter(context); if (filter == null) { return null; } diff --git a/core/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java index 7172c745927..674cad70872 100644 --- a/core/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -31,7 +30,7 @@ import java.util.Collection; /** * Parser for {@link IndicesQueryBuilder}. */ -public class IndicesQueryParser extends BaseQueryParser { +public class IndicesQueryParser implements QueryParser { private static final ParseField QUERY_FIELD = new ParseField("query", "filter"); private static final ParseField NO_MATCH_QUERY = new ParseField("no_match_query", "no_match_filter"); @@ -97,7 +96,7 @@ public class IndicesQueryParser extends BaseQueryParser { } } } - + if (innerQuery == null) { throw new ParsingException(parser.getTokenLocation(), "[indices] requires 'query' element"); } diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java index 3d67a276637..770f9c3dd67 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for match_all query */ -public class MatchAllQueryParser extends BaseQueryParser { +public class MatchAllQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java index 0f177b41cb3..7135836271f 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java @@ -21,12 +21,11 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; -public class MatchNoneQueryParser extends BaseQueryParser { +public class MatchNoneQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java index bf0dcb9f22b..afcf25ca2a7 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.apache.lucene.search.FuzzyQuery; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.search.MatchQuery; @@ -32,7 +31,7 @@ import java.io.IOException; /** * */ -public class MatchQueryParser extends BaseQueryParser { +public class MatchQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java index df6d31aaae3..8d8c5aec01f 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java @@ -27,7 +27,7 @@ import java.io.IOException; /** * Parser for missing query */ -public class MissingQueryParser extends BaseQueryParser { +public class MissingQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java index 41dc9041553..f7c1945313d 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java @@ -33,7 +33,7 @@ import java.util.List; * * The documents are provided as a set of strings and/or a list of {@link Item}. */ -public class MoreLikeThisQueryParser extends BaseQueryParser { +public class MoreLikeThisQueryParser implements QueryParser { public interface Field { ParseField FIELDS = new ParseField("fields"); diff --git a/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java index 99481493a29..c86d0295577 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java @@ -31,7 +31,7 @@ import java.util.Map; /** * Same as {@link MatchQueryParser} but has support for multiple fields. */ -public class MultiMatchQueryParser extends BaseQueryParser { +public class MultiMatchQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java index 0567ff23f12..1fabfede29d 100644 --- a/core/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java @@ -19,26 +19,15 @@ package org.elasticsearch.index.query; -import org.apache.lucene.search.ConstantScoreQuery; -import org.apache.lucene.search.Query; import org.apache.lucene.search.join.ScoreMode; -import org.apache.lucene.search.join.ToParentBlockJoinQuery; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.query.support.InnerHitsQueryParserHelper; -import org.elasticsearch.index.query.support.NestedInnerQueryParseSupport; import org.elasticsearch.index.query.support.QueryInnerHits; -import org.elasticsearch.search.fetch.innerhits.InnerHitsContext; -import org.elasticsearch.search.fetch.innerhits.InnerHitsSubSearchContext; - import java.io.IOException; -public class NestedQueryParser extends BaseQueryParser { +public class NestedQueryParser implements QueryParser { private static final ParseField FILTER_FIELD = new ParseField("filter").withAllDeprecated("query"); private static final NestedQueryBuilder PROTOTYPE = new NestedQueryBuilder("", EmptyQueryBuilder.PROTOTYPE); @@ -66,7 +55,7 @@ public class NestedQueryParser extends BaseQueryParser { if ("query".equals(currentFieldName)) { query = parseContext.parseInnerQueryBuilder(); } else if (parseContext.parseFieldMatcher().match(currentFieldName, FILTER_FIELD)) { - query = parseContext.parseInnerFilterToQueryBuilder(); + query = parseContext.parseInnerQueryBuilder(); } else if ("inner_hits".equals(currentFieldName)) { queryInnerHits = new QueryInnerHits(parser); } else { diff --git a/core/src/main/java/org/elasticsearch/index/query/NotQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/NotQueryParser.java index 5f34d84b6d2..de458209b07 100644 --- a/core/src/main/java/org/elasticsearch/index/query/NotQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/NotQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for not query */ -public class NotQueryParser extends BaseQueryParser { +public class NotQueryParser implements QueryParser { private static final ParseField QUERY_FIELD = new ParseField("query", "filter"); @@ -56,12 +55,12 @@ public class NotQueryParser extends BaseQueryParser { // skip } else if (token == XContentParser.Token.START_OBJECT) { if (parseContext.parseFieldMatcher().match(currentFieldName, QUERY_FIELD)) { - query = parseContext.parseInnerFilterToQueryBuilder(); + query = parseContext.parseInnerQueryBuilder(); queryFound = true; } else { queryFound = true; // its the filter, and the name is the field - query = parseContext.parseInnerFilterToQueryBuilder(currentFieldName); + query = parseContext.parseInnerQueryBuilderByName(currentFieldName); } } else if (token.isValue()) { if ("_name".equals(currentFieldName)) { diff --git a/core/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java index e640f3bc060..a8dca4c7816 100644 --- a/core/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for prefix query */ -public class PrefixQueryParser extends BaseQueryParser { +public class PrefixQueryParser implements QueryParser { private static final ParseField NAME_FIELD = new ParseField("_name").withAllDeprecated("query name is not supported in short version of prefix query"); diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java b/core/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java index 44aa92652ea..e13661c814c 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java @@ -19,8 +19,6 @@ package org.elasticsearch.index.query; -import org.elasticsearch.common.ParsingException; - import java.io.IOException; /** @@ -29,7 +27,7 @@ import java.io.IOException; */ // TODO: remove when https://github.com/elastic/elasticsearch/issues/13326 is fixed @Deprecated -public class QueryFilterParser extends BaseQueryParser { +public class QueryFilterParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java b/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java index 6c698e7657d..5accd2823fe 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java @@ -19,8 +19,6 @@ package org.elasticsearch.index.query; -import org.apache.lucene.search.Query; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.ParsingException; @@ -60,12 +58,6 @@ public class QueryParseContext { } } - //norelease this is still used in BaseQueryParserTemp and FunctionScoreQueryParser, remove if not needed there anymore - @Deprecated - public QueryShardContext shardContext() { - return this.shardContext; - } - public XContentParser parser() { return this.parser; } @@ -81,37 +73,6 @@ public class QueryParseContext { return parseFieldMatcher.match(setting, CACHE) || parseFieldMatcher.match(setting, CACHE_KEY); } - /** - * @deprecated replaced by calls to parseInnerFilterToQueryBuilder() for the resulting queries - */ - @Nullable - @Deprecated - //norelease should be possible to remove after refactoring all queries - public Query parseInnerFilter() throws QueryShardException, IOException { - assert this.shardContext != null; - QueryBuilder builder = parseInnerFilterToQueryBuilder(); - Query result = null; - if (builder != null) { - result = builder.toQuery(this.shardContext); - } - return result; - } - - /** - * @deprecated replaced by calls to parseInnerQueryBuilder() for the resulting queries - */ - @Nullable - @Deprecated - //norelease this method will be removed once all queries are refactored - public Query parseInnerQuery() throws IOException, QueryShardException { - QueryBuilder builder = parseInnerQueryBuilder(); - Query result = null; - if (builder != null) { - result = builder.toQuery(this.shardContext); - } - return result; - } - /** * @return a new QueryBuilder based on the current state of the parser */ @@ -139,11 +100,7 @@ public class QueryParseContext { throw new ParsingException(parser.getTokenLocation(), "[_na] query malformed, no field after start_object"); } - QueryParser queryParser = queryParser(queryName); - if (queryParser == null) { - throw new ParsingException(parser.getTokenLocation(), "No query registered for [" + queryName + "]"); - } - QueryBuilder result = queryParser.fromXContent(this); + QueryBuilder result = parseInnerQueryBuilderByName(queryName); if (parser.currentToken() == XContentParser.Token.END_OBJECT || parser.currentToken() == XContentParser.Token.END_ARRAY) { // if we are at END_OBJECT, move to the next one... parser.nextToken(); @@ -151,34 +108,12 @@ public class QueryParseContext { return result; } - /** - * @return a new QueryBuilder based on the current state of the parser, but does so that the inner query - * is parsed to a filter - */ - //norelease setting and checking the isFilter Flag should completely be moved to toQuery/toFilter after query refactoring - public QueryBuilder parseInnerFilterToQueryBuilder() throws IOException { - final boolean originalIsFilter = this.shardContext.isFilter; - try { - this.shardContext.isFilter = true; - return parseInnerQueryBuilder(); - } finally { - this.shardContext.isFilter = originalIsFilter; - } - } - - //norelease setting and checking the isFilter Flag should completely be moved to toQuery/toFilter after query refactoring - public QueryBuilder parseInnerFilterToQueryBuilder(String queryName) throws IOException { - final boolean originalIsFilter = this.shardContext.isFilter; - try { - this.shardContext.isFilter = true; - QueryParser queryParser = queryParser(queryName); - if (queryParser == null) { - throw new ParsingException(parser.getTokenLocation(), "No query registered for [" + queryName + "]"); - } - return queryParser.fromXContent(this); - } finally { - this.shardContext.isFilter = originalIsFilter; + public QueryBuilder parseInnerQueryBuilderByName(String queryName) throws IOException { + QueryParser queryParser = queryParser(queryName); + if (queryParser == null) { + throw new ParsingException(parser.getTokenLocation(), "No query registered for [" + queryName + "]"); } + return queryParser.fromXContent(this); } public ParseFieldMatcher parseFieldMatcher() { @@ -189,6 +124,11 @@ public class QueryParseContext { this.parser = innerParser; } + /** + * Get the query parser for a specific type of query registered under its name + * @param name the name of the parser to retrieve + * @return the query parser + */ QueryParser queryParser(String name) { return indicesQueriesRegistry.queryParsers().get(name); } diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryParser.java b/core/src/main/java/org/elasticsearch/index/query/QueryParser.java index 56128b69cfd..0a3f6d6147c 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryParser.java @@ -19,9 +19,6 @@ package org.elasticsearch.index.query; -import org.apache.lucene.search.Query; -import org.elasticsearch.common.Nullable; - import java.io.IOException; /** @@ -35,18 +32,6 @@ public interface QueryParser> { */ String[] names(); - /** - * Parses the into a query from the current parser location. Will be at - * "START_OBJECT" location, and should end when the token is at the matching - * "END_OBJECT". - *

- * Returns null if this query should be ignored in the context of - * the DSL. - */ - //norelease can be removed in favour of fromXContent once search requests can be parsed on the coordinating node - @Nullable - Query parse(QueryShardContext context) throws IOException; - /** * Creates a new {@link QueryBuilder} from the query held by the {@link QueryShardContext} * in {@link org.elasticsearch.common.xcontent.XContent} format diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java index c0bda6fd777..f5dbb250805 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java @@ -22,7 +22,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.xcontent.XContentParser; @@ -34,7 +33,7 @@ import java.util.Map; /** * Parser for query_string query */ -public class QueryStringQueryParser extends BaseQueryParser { +public class QueryStringQueryParser implements QueryParser { private static final ParseField FUZZINESS = Fuzziness.FIELD.withDeprecation("fuzzy_min_sim"); diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryWrappingQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/QueryWrappingQueryBuilder.java deleted file mode 100644 index e905de1c17f..00000000000 --- a/core/src/main/java/org/elasticsearch/index/query/QueryWrappingQueryBuilder.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.query; - -import org.apache.lucene.search.Query; -import org.elasticsearch.common.xcontent.XContentBuilder; - -import java.io.IOException; - -/** - * QueryBuilder implementation that holds a lucene query, which can be returned by {@link QueryBuilder#toQuery(QueryShardContext)}. - * Doesn't support conversion to {@link org.elasticsearch.common.xcontent.XContent} via {@link #doXContent(XContentBuilder, Params)}. - */ -//norelease to be removed once all queries support separate fromXContent and toQuery methods. Make AbstractQueryBuilder#toQuery final as well then. -public class QueryWrappingQueryBuilder extends AbstractQueryBuilder implements SpanQueryBuilder, MultiTermQueryBuilder{ - - private Query query; - - public QueryWrappingQueryBuilder(Query query) { - this.query = query; - } - - @Override - protected void doXContent(XContentBuilder builder, Params params) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - protected Query doToQuery(QueryShardContext context) throws IOException { - return query; - } - - @Override - public String getWriteableName() { - // this should not be called since we overwrite BaseQueryBuilder#toQuery() in this class - throw new UnsupportedOperationException(); - } - - @Override - protected void setFinalBoost(Query query) { - //no-op the wrapper lucene query has already its boost set - } -} diff --git a/core/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java index 7c02dd9c386..dcd07b3e4eb 100644 --- a/core/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java @@ -28,7 +28,7 @@ import java.io.IOException; /** * Parser for range query */ -public class RangeQueryParser extends BaseQueryParser { +public class RangeQueryParser implements QueryParser { private static final ParseField FIELDDATA_FIELD = new ParseField("fielddata").withAllDeprecated("[no replacement]"); private static final ParseField NAME_FIELD = new ParseField("_name").withAllDeprecated("query name is not supported in short version of range query"); diff --git a/core/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java index 40eb4bb052e..d07c23da171 100644 --- a/core/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for regexp query */ -public class RegexpQueryParser extends BaseQueryParser { +public class RegexpQueryParser implements QueryParser { private static final ParseField NAME_FIELD = new ParseField("_name").withAllDeprecated("query name is not supported in short version of regexp query"); diff --git a/core/src/main/java/org/elasticsearch/index/query/ScriptQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/ScriptQueryParser.java index 632883b69df..97ad0a21873 100644 --- a/core/src/main/java/org/elasticsearch/index/query/ScriptQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/ScriptQueryParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.script.Script; import org.elasticsearch.script.Script.ScriptField; @@ -34,7 +33,7 @@ import java.util.Map; /** * Parser for script query */ -public class ScriptQueryParser extends BaseQueryParser { +public class ScriptQueryParser implements QueryParser { @Override public String[] names() { @@ -45,7 +44,7 @@ public class ScriptQueryParser extends BaseQueryParser { public ScriptQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { XContentParser parser = parseContext.parser(); ScriptParameterParser scriptParameterParser = new ScriptParameterParser(); - + // also, when caching, since its isCacheable is false, will result in loading all bit set... Script script = null; Map params = null; diff --git a/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java b/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java index 9417d85b533..c803d440055 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java @@ -19,10 +19,8 @@ package org.elasticsearch.index.query; -import org.apache.lucene.search.BooleanQuery; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -60,7 +58,7 @@ import java.util.Map; * {@code fields} - fields to search, defaults to _all if not set, allows * boosting a field with ^n */ -public class SimpleQueryStringParser extends BaseQueryParser { +public class SimpleQueryStringParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanContainingQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanContainingQueryParser.java index 97f41539a02..51dddac19e4 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanContainingQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanContainingQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for span_containing query */ -public class SpanContainingQueryParser extends BaseQueryParser { +public class SpanContainingQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java index f9be0e8b998..e417b45bed3 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java @@ -28,7 +28,7 @@ import java.io.IOException; /** * Parser for span_first query */ -public class SpanFirstQueryParser extends BaseQueryParser { +public class SpanFirstQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryParser.java index 3c02641a33b..e51b693187c 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -28,7 +27,7 @@ import java.io.IOException; /** * Parser for span_multi query */ -public class SpanMultiTermQueryParser extends BaseQueryParser { +public class SpanMultiTermQueryParser implements QueryParser { public static final String MATCH_NAME = "match"; diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java index d9a1bdda775..4600f698231 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java @@ -30,7 +30,7 @@ import java.util.List; /** * Parser for span_near query */ -public class SpanNearQueryParser extends BaseQueryParser { +public class SpanNearQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java index 85ed30b3340..4b4876c8cff 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for span_not query */ -public class SpanNotQueryParser extends BaseQueryParser { +public class SpanNotQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java index 9cb1afc36cd..a0dabbdad06 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java @@ -30,7 +30,7 @@ import java.util.List; /** * Parser for span_or query */ -public class SpanOrQueryParser extends BaseQueryParser { +public class SpanOrQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java index 763a7b6389c..5caefac77b6 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for span_term query */ -public class SpanTermQueryParser extends BaseQueryParser { +public class SpanTermQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanWithinQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanWithinQueryParser.java index 6130ad30ae3..1acb4eaecd2 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanWithinQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanWithinQueryParser.java @@ -28,7 +28,7 @@ import java.io.IOException; /** * Parser for span_within query */ -public class SpanWithinQueryParser extends BaseQueryParser { +public class SpanWithinQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/TemplateQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/TemplateQueryParser.java index e08f7041c07..0df2460c847 100644 --- a/core/src/main/java/org/elasticsearch/index/query/TemplateQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/TemplateQueryParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseFieldMatcher; -import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.Template; @@ -33,7 +32,7 @@ import java.util.Map; * In the simplest case, parse template string and variables from the request, * compile the template and execute the template against the given variables. * */ -public class TemplateQueryParser extends BaseQueryParser { +public class TemplateQueryParser implements QueryParser { private final static Map parametersToTypes = new HashMap<>(); static { diff --git a/core/src/main/java/org/elasticsearch/index/query/TermQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/TermQueryParser.java index eff5ec84d65..0591497a3c8 100644 --- a/core/src/main/java/org/elasticsearch/index/query/TermQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/TermQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for the term query */ -public class TermQueryParser extends BaseQueryParser { +public class TermQueryParser implements QueryParser { private static final ParseField NAME_FIELD = new ParseField("_name").withAllDeprecated("query name is not supported in short version of term query"); private static final ParseField BOOST_FIELD = new ParseField("boost").withAllDeprecated("boost is not supported in short version of term query"); diff --git a/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java index 1dfa023783a..c76369195a3 100644 --- a/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java @@ -36,7 +36,7 @@ import java.util.List; * It also supports a terms lookup mechanism which can be used to fetch the term values from * a document in an index. */ -public class TermsQueryParser extends BaseQueryParser { +public class TermsQueryParser implements QueryParser { private static final ParseField MIN_SHOULD_MATCH_FIELD = new ParseField("min_match", "min_should_match", "minimum_should_match") .withAllDeprecated("Use [bool] query instead"); diff --git a/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java index 1edbe5a95bf..e2b4e13c65e 100644 --- a/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.query; import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -29,7 +28,7 @@ import java.io.IOException; /** * Parser for type query */ -public class TypeQueryParser extends BaseQueryParser { +public class TypeQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java index cd14d47b539..4967f2e11c4 100644 --- a/core/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -28,7 +27,7 @@ import java.io.IOException; /** * Parser for wildcard query */ -public class WildcardQueryParser extends BaseQueryParser { +public class WildcardQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java index 9debfad6a2e..59c570e97f9 100644 --- a/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; @@ -28,7 +27,7 @@ import java.io.IOException; /** * Query parser for JSON Queries. */ -public class WrapperQueryParser extends BaseQueryParser { +public class WrapperQueryParser implements QueryParser { @Override public String[] names() { diff --git a/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryParser.java index 2bb35b0a5ec..7adde617009 100644 --- a/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryParser.java @@ -38,7 +38,7 @@ import java.util.List; /** * Parser for function_score query */ -public class FunctionScoreQueryParser extends BaseQueryParser { +public class FunctionScoreQueryParser implements QueryParser { private static final FunctionScoreQueryBuilder PROTOTYPE = new FunctionScoreQueryBuilder(EmptyQueryBuilder.PROTOTYPE, new FunctionScoreQueryBuilder.FilterFunctionBuilder[0]); @@ -88,7 +88,7 @@ public class FunctionScoreQueryParser extends BaseQueryParser { @Override public String[] names() { return new String[]{DummyQueryBuilder.NAME}; } @Override - public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { + public DummyQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { XContentParser.Token token = parseContext.parser().nextToken(); assert token == XContentParser.Token.END_OBJECT; return new DummyQueryBuilder(); diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java b/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java index fdd85596057..c7a2624d380 100644 --- a/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java +++ b/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.indices; import org.apache.lucene.analysis.hunspell.Dictionary; -import org.apache.lucene.search.Query; import org.elasticsearch.common.inject.ModuleTestCase; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.*; @@ -42,11 +41,6 @@ public class IndicesModuleTests extends ModuleTestCase { return null; } - @Override - public Query parse(QueryShardContext context) throws IOException { - return null; - } - @Override public QueryBuilder getBuilderPrototype() { return null;