Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -587,10 +587,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 @@ -588,6 +588,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