Skip to content

Commit

Permalink
Merge pull request #17710 from colings86/deprecate/indicesQuery
Browse files Browse the repository at this point in the history
Deprecate Indices query
  • Loading branch information
colings86 committed Apr 14, 2016
2 parents d84c643 + b226cc7 commit 90d0443
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
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;

Expand All @@ -34,9 +36,13 @@
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<IndicesQueryBuilder> {

public static final String NAME = "indices";
Expand All @@ -47,13 +53,20 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
private static final ParseField INDEX_FIELD = new ParseField("index");
private static final ParseField INDICES_FIELD = new ParseField("indices");

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(IndicesQueryBuilder.class));

private final QueryBuilder<?> 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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,14 @@ public static TermsQueryBuilder termsQuery(String name, Collection<?> values) {
}

/**
* 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ private void registerBuiltinQueryParsers() {
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);
Expand Down

0 comments on commit 90d0443

Please sign in to comment.