Merge pull request #17710 from colings86/deprecate/indicesQuery
Deprecate Indices query
This commit is contained in:
commit
90d044309f
|
@ -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<IndicesQueryBuilder> {
|
||||
|
||||
public static final String NAME = "indices";
|
||||
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -591,10 +591,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -593,6 +593,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);
|
||||
|
|
Loading…
Reference in New Issue