From b226cc7e7f4b083bb1a0d6958200a95afbff4c5b Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Wed, 13 Apr 2016 12:35:14 +0100 Subject: [PATCH] Deprecate Indices query This is in favour of just searching the _index field Closes #12017 --- .../index/query/IndicesQueryBuilder.java | 17 +++++++++++++++-- .../index/query/QueryBuilders.java | 8 ++++++-- .../org/elasticsearch/search/SearchModule.java | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java index 477e55812cb..d5caa16ea71 100644 --- a/core/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java @@ -24,6 +24,8 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -34,9 +36,13 @@ import java.util.Collection; import java.util.Objects; /** - * A query that will execute the wrapped query only for the specified indices, and "match_all" when - * it does not match those indices (by default). + * A query that will execute the wrapped query only for the specified indices, + * and "match_all" when it does not match those indices (by default). + * + * @deprecated instead search on the `_index` field */ +@Deprecated +// TODO remove this class in 6.0 public class IndicesQueryBuilder extends AbstractQueryBuilder { public static final String NAME = "indices"; @@ -47,13 +53,20 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder innerQuery; private final String[] indices; private QueryBuilder noMatchQuery = defaultNoMatchQuery(); + /** + * @deprecated instead search on the `_index` field + */ + @Deprecated public IndicesQueryBuilder(QueryBuilder innerQuery, String... indices) { + DEPRECATION_LOGGER.deprecated("{} query is deprecated. Instead search on the '_index' field", NAME); if (innerQuery == null) { throw new IllegalArgumentException("inner query cannot be null"); } diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryBuilders.java b/core/src/main/java/org/elasticsearch/index/query/QueryBuilders.java index f04f03fcbcd..7466836c543 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryBuilders.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryBuilders.java @@ -587,10 +587,14 @@ public abstract class QueryBuilders { } /** - * A query that will execute the wrapped query only for the specified indices, and "match_all" when - * it does not match those indices. + * A query that will execute the wrapped query only for the specified + * indices, and "match_all" when it does not match those indices. + * + * @deprecated instead search on the `_index` field */ + @Deprecated public static IndicesQueryBuilder indicesQuery(QueryBuilder queryBuilder, String... indices) { + // TODO remove this method in 6.0 return new IndicesQueryBuilder(queryBuilder, indices); } diff --git a/core/src/main/java/org/elasticsearch/search/SearchModule.java b/core/src/main/java/org/elasticsearch/search/SearchModule.java index 597429529ee..227769e78df 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchModule.java +++ b/core/src/main/java/org/elasticsearch/search/SearchModule.java @@ -588,6 +588,7 @@ public class SearchModule extends AbstractModule { registerQuery(SpanOrQueryBuilder::new, SpanOrQueryBuilder::fromXContent, SpanOrQueryBuilder.QUERY_NAME_FIELD); registerQuery(MoreLikeThisQueryBuilder::new, MoreLikeThisQueryBuilder::fromXContent, MoreLikeThisQueryBuilder.QUERY_NAME_FIELD); registerQuery(WrapperQueryBuilder::new, WrapperQueryBuilder::fromXContent, WrapperQueryBuilder.QUERY_NAME_FIELD); + // TODO Remove IndicesQuery in 6.0 registerQuery(IndicesQueryBuilder::new, IndicesQueryBuilder::fromXContent, IndicesQueryBuilder.QUERY_NAME_FIELD); registerQuery(CommonTermsQueryBuilder::new, CommonTermsQueryBuilder::fromXContent, CommonTermsQueryBuilder.QUERY_NAME_FIELD); registerQuery(SpanMultiTermQueryBuilder::new, SpanMultiTermQueryBuilder::fromXContent, SpanMultiTermQueryBuilder.QUERY_NAME_FIELD);