QueryBuilder does not need generics. #18133

QueryBuilder has generics, but those are never used: all call sites use
`QueryBuilder<?>`. Only `AbstractQueryBuilder` needs generics so that the base
class can contain a default implementation for setters that returns `this`.
This commit is contained in:
Adrien Grand 2016-05-04 15:18:13 +02:00
parent 1199cd8e2a
commit 7d8708716e
103 changed files with 359 additions and 354 deletions

View File

@ -34,7 +34,7 @@ import java.io.IOException;
*/
public class ShardValidateQueryRequest extends BroadcastShardRequest {
private QueryBuilder<?> query;
private QueryBuilder query;
private String[] types = Strings.EMPTY_ARRAY;
private boolean explain;
private boolean rewrite;
@ -57,7 +57,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest {
this.nowInMillis = request.nowInMillis;
}
public QueryBuilder<?> query() {
public QueryBuilder query() {
return query;
}

View File

@ -39,7 +39,7 @@ import java.util.Arrays;
*/
public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest> {
private QueryBuilder<?> query = new MatchAllQueryBuilder();
private QueryBuilder query = new MatchAllQueryBuilder();
private boolean explain;
private boolean rewrite;
@ -73,11 +73,11 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
/**
* The query to validate.
*/
public QueryBuilder<?> query() {
public QueryBuilder query() {
return query;
}
public ValidateQueryRequest query(QueryBuilder<?> query) {
public ValidateQueryRequest query(QueryBuilder query) {
this.query = query;
return this;
}

View File

@ -39,7 +39,7 @@ public class ExplainRequest extends SingleShardRequest<ExplainRequest> {
private String id;
private String routing;
private String preference;
private QueryBuilder<?> query;
private QueryBuilder query;
private String[] fields;
private FetchSourceContext fetchSourceContext;
@ -100,11 +100,11 @@ public class ExplainRequest extends SingleShardRequest<ExplainRequest> {
return this;
}
public QueryBuilder<?> query() {
public QueryBuilder query() {
return query;
}
public ExplainRequest query(QueryBuilder<?> query) {
public ExplainRequest query(QueryBuilder query) {
this.query = query;
return this;
}

View File

@ -48,7 +48,7 @@ import java.util.Map;
public class PercolateSourceBuilder extends ToXContentToBytes {
private DocBuilder docBuilder;
private QueryBuilder<?> queryBuilder;
private QueryBuilder queryBuilder;
private Integer size;
private List<SortBuilder<?>> sorts;
private Boolean trackScores;
@ -68,7 +68,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes {
* Sets a query to reduce the number of percolate queries to be evaluated and score the queries that match based
* on this query.
*/
public PercolateSourceBuilder setQueryBuilder(QueryBuilder<?> queryBuilder) {
public PercolateSourceBuilder setQueryBuilder(QueryBuilder queryBuilder) {
this.queryBuilder = queryBuilder;
return this;
}

View File

@ -203,7 +203,7 @@ public class TransportPercolateAction extends HandledTransportAction<PercolateRe
if (querySource != null) {
try (XContentParser parser = XContentHelper.createParser(querySource)) {
QueryParseContext queryParseContext = new QueryParseContext(queryRegistry, parser, parseFieldMatcher);
QueryBuilder<?> queryBuilder = queryParseContext.parseInnerQueryBuilder();
QueryBuilder queryBuilder = queryParseContext.parseInnerQueryBuilder();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(queryBuilder);
boolQueryBuilder.filter(percolateQueryBuilder);

View File

@ -166,7 +166,7 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
*
* @see org.elasticsearch.index.query.QueryBuilders
*/
public SearchRequestBuilder setQuery(QueryBuilder<?> queryBuilder) {
public SearchRequestBuilder setQuery(QueryBuilder queryBuilder) {
sourceBuilder().query(queryBuilder);
return this;
}
@ -175,7 +175,7 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
* Sets a filter that will be executed after the query has been executed and only has affect on the search hits
* (not aggregations). This filter is always executed as last filtering mechanism.
*/
public SearchRequestBuilder setPostFilter(QueryBuilder<?> postFilter) {
public SearchRequestBuilder setPostFilter(QueryBuilder postFilter) {
sourceBuilder().postFilter(postFilter);
return this;
}

View File

@ -141,7 +141,7 @@ public class AliasValidator extends AbstractComponent {
private static void validateAliasFilter(XContentParser parser, QueryShardContext queryShardContext) throws IOException {
QueryParseContext queryParseContext = queryShardContext.newParseContext(parser);
QueryBuilder<?> queryBuilder = QueryBuilder.rewriteQuery(queryParseContext.parseInnerQueryBuilder(), queryShardContext);
QueryBuilder queryBuilder = QueryBuilder.rewriteQuery(queryParseContext.parseInnerQueryBuilder(), queryShardContext);
queryBuilder.toFilter(queryShardContext);
}
}

View File

@ -186,7 +186,7 @@ public class PercolatorFieldMapper extends FieldMapper {
}
XContentParser parser = context.parser();
QueryBuilder<?> queryBuilder = parseQueryBuilder(queryShardContext.newParseContext(parser), parser.getTokenLocation());
QueryBuilder queryBuilder = parseQueryBuilder(queryShardContext.newParseContext(parser), parser.getTokenLocation());
// Fetching of terms, shapes and indexed scripts happen during this rewrite:
queryBuilder = queryBuilder.rewrite(queryShardContext);
@ -206,7 +206,7 @@ public class PercolatorFieldMapper extends FieldMapper {
return toQuery(context, mapUnmappedFieldsAsString, parseQueryBuilder(context.newParseContext(parser), parser.getTokenLocation()));
}
static Query toQuery(QueryShardContext context, boolean mapUnmappedFieldsAsString, QueryBuilder<?> queryBuilder) throws IOException {
static Query toQuery(QueryShardContext context, boolean mapUnmappedFieldsAsString, QueryBuilder queryBuilder) throws IOException {
// This means that fields in the query need to exist in the mapping prior to registering this query
// The reason that this is required, is that if a field doesn't exist then the query assumes defaults, which may be undesired.
//

View File

@ -43,7 +43,7 @@ import java.util.Objects;
* Base class for all classes producing lucene queries.
* Supports conversion to BytesReference and creation of lucene Query objects.
*/
public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>> extends ToXContentToBytes implements QueryBuilder<QB> {
public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>> extends ToXContentToBytes implements QueryBuilder {
/** Default for boost to apply to resulting Lucene query. Defaults to 1.0*/
public static final float DEFAULT_BOOST = 1.0f;
@ -221,10 +221,10 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
* their {@link QueryBuilder#toQuery(QueryShardContext)} method are not added to the
* resulting collection.
*/
protected static Collection<Query> toQueries(Collection<QueryBuilder<?>> queryBuilders, QueryShardContext context) throws QueryShardException,
protected static Collection<Query> toQueries(Collection<QueryBuilder> queryBuilders, QueryShardContext context) throws QueryShardException,
IOException {
List<Query> queries = new ArrayList<>(queryBuilders.size());
for (QueryBuilder<?> queryBuilder : queryBuilders) {
for (QueryBuilder queryBuilder : queryBuilders) {
Query query = queryBuilder.toQuery(context);
if (query != null) {
queries.add(query);
@ -241,13 +241,13 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
protected final static void writeQueries(StreamOutput out, List<? extends QueryBuilder> queries) throws IOException {
out.writeVInt(queries.size());
for (QueryBuilder<?> query : queries) {
for (QueryBuilder query : queries) {
out.writeNamedWriteable(query);
}
}
protected final static List<QueryBuilder<?>> readQueries(StreamInput in) throws IOException {
List<QueryBuilder<?>> queries = new ArrayList<>();
protected final static List<QueryBuilder> readQueries(StreamInput in) throws IOException {
List<QueryBuilder> queries = new ArrayList<>();
int size = in.readVInt();
for (int i = 0; i < size; i++) {
queries.add(in.readNamedWriteable(QueryBuilder.class));
@ -256,8 +256,8 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
}
@Override
public final QueryBuilder<?> rewrite(QueryRewriteContext queryShardContext) throws IOException {
QueryBuilder<?> rewritten = doRewrite(queryShardContext);
public final QueryBuilder rewrite(QueryRewriteContext queryShardContext) throws IOException {
QueryBuilder rewritten = doRewrite(queryShardContext);
if (rewritten == this) {
return rewritten;
}
@ -270,7 +270,7 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
return rewritten;
}
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryShardContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
return this;
}

View File

@ -62,13 +62,13 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
private static final ParseField MINIMUM_NUMBER_SHOULD_MATCH = new ParseField("minimum_number_should_match");
private static final ParseField ADJUST_PURE_NEGATIVE = new ParseField("adjust_pure_negative");
private final List<QueryBuilder<?>> mustClauses = new ArrayList<>();
private final List<QueryBuilder> mustClauses = new ArrayList<>();
private final List<QueryBuilder<?>> mustNotClauses = new ArrayList<>();
private final List<QueryBuilder> mustNotClauses = new ArrayList<>();
private final List<QueryBuilder<?>> filterClauses = new ArrayList<>();
private final List<QueryBuilder> filterClauses = new ArrayList<>();
private final List<QueryBuilder<?>> shouldClauses = new ArrayList<>();
private final List<QueryBuilder> shouldClauses = new ArrayList<>();
private boolean disableCoord = DISABLE_COORD_DEFAULT;
@ -111,7 +111,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
* Adds a query that <b>must</b> appear in the matching documents and will
* contribute to scoring. No <tt>null</tt> value allowed.
*/
public BoolQueryBuilder must(QueryBuilder<?> queryBuilder) {
public BoolQueryBuilder must(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@ -122,7 +122,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
/**
* Gets the queries that <b>must</b> appear in the matching documents.
*/
public List<QueryBuilder<?>> must() {
public List<QueryBuilder> must() {
return this.mustClauses;
}
@ -130,7 +130,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
* Adds a query that <b>must</b> appear in the matching documents but will
* not contribute to scoring. No <tt>null</tt> value allowed.
*/
public BoolQueryBuilder filter(QueryBuilder<?> queryBuilder) {
public BoolQueryBuilder filter(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@ -141,7 +141,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
/**
* Gets the queries that <b>must</b> appear in the matching documents but don't contribute to scoring
*/
public List<QueryBuilder<?>> filter() {
public List<QueryBuilder> filter() {
return this.filterClauses;
}
@ -149,7 +149,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
* Adds a query that <b>must not</b> appear in the matching documents.
* No <tt>null</tt> value allowed.
*/
public BoolQueryBuilder mustNot(QueryBuilder<?> queryBuilder) {
public BoolQueryBuilder mustNot(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@ -160,7 +160,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
/**
* Gets the queries that <b>must not</b> appear in the matching documents.
*/
public List<QueryBuilder<?>> mustNot() {
public List<QueryBuilder> mustNot() {
return this.mustNotClauses;
}
@ -171,7 +171,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
*
* @see #minimumNumberShouldMatch(int)
*/
public BoolQueryBuilder should(QueryBuilder<?> queryBuilder) {
public BoolQueryBuilder should(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@ -185,7 +185,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
* @see #should(QueryBuilder)
* @see #minimumNumberShouldMatch(int)
*/
public List<QueryBuilder<?>> should() {
public List<QueryBuilder> should() {
return this.shouldClauses;
}
@ -288,13 +288,13 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
builder.endObject();
}
private static void doXArrayContent(String field, List<QueryBuilder<?>> clauses, XContentBuilder builder, Params params)
private static void doXArrayContent(String field, List<QueryBuilder> clauses, XContentBuilder builder, Params params)
throws IOException {
if (clauses.isEmpty()) {
return;
}
builder.startArray(field);
for (QueryBuilder<?> clause : clauses) {
for (QueryBuilder clause : clauses) {
clause.toXContent(builder, params);
}
builder.endArray();
@ -308,15 +308,15 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String minimumShouldMatch = null;
final List<QueryBuilder<?>> mustClauses = new ArrayList<>();
final List<QueryBuilder<?>> mustNotClauses = new ArrayList<>();
final List<QueryBuilder<?>> shouldClauses = new ArrayList<>();
final List<QueryBuilder<?>> filterClauses = new ArrayList<>();
final List<QueryBuilder> mustClauses = new ArrayList<>();
final List<QueryBuilder> mustNotClauses = new ArrayList<>();
final List<QueryBuilder> shouldClauses = new ArrayList<>();
final List<QueryBuilder> filterClauses = new ArrayList<>();
String queryName = null;
String currentFieldName = null;
XContentParser.Token token;
QueryBuilder<?> query;
QueryBuilder query;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
@ -387,16 +387,16 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
}
}
BoolQueryBuilder boolQuery = new BoolQueryBuilder();
for (QueryBuilder<?> queryBuilder : mustClauses) {
for (QueryBuilder queryBuilder : mustClauses) {
boolQuery.must(queryBuilder);
}
for (QueryBuilder<?> queryBuilder : mustNotClauses) {
for (QueryBuilder queryBuilder : mustNotClauses) {
boolQuery.mustNot(queryBuilder);
}
for (QueryBuilder<?> queryBuilder : shouldClauses) {
for (QueryBuilder queryBuilder : shouldClauses) {
boolQuery.should(queryBuilder);
}
for (QueryBuilder<?> queryBuilder : filterClauses) {
for (QueryBuilder queryBuilder : filterClauses) {
boolQuery.filter(queryBuilder);
}
boolQuery.boost(boost);
@ -436,8 +436,8 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
}
private static void addBooleanClauses(QueryShardContext context, BooleanQuery.Builder booleanQueryBuilder,
List<QueryBuilder<?>> clauses, Occur occurs) throws IOException {
for (QueryBuilder<?> query : clauses) {
List<QueryBuilder> clauses, Occur occurs) throws IOException {
for (QueryBuilder query : clauses) {
Query luceneQuery = null;
switch (occurs) {
case MUST:
@ -473,7 +473,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
BoolQueryBuilder newBuilder = new BoolQueryBuilder();
boolean changed = false;
final int clauses = mustClauses.size() + mustNotClauses.size() + filterClauses.size() + shouldClauses.size();
@ -498,20 +498,20 @@ public class BoolQueryBuilder extends AbstractQueryBuilder<BoolQueryBuilder> {
@Override
protected void extractInnerHitBuilders(Map<String, InnerHitBuilder> innerHits) {
List<QueryBuilder<?>> clauses = new ArrayList<>(filter());
List<QueryBuilder> clauses = new ArrayList<>(filter());
clauses.addAll(must());
clauses.addAll(should());
// no need to include must_not (since there will be no hits for it)
for (QueryBuilder<?> clause : clauses) {
for (QueryBuilder clause : clauses) {
InnerHitBuilder.extractInnerHits(clause, innerHits);
}
}
private static boolean rewriteClauses(QueryRewriteContext queryRewriteContext, List<QueryBuilder<?>> builders,
Consumer<QueryBuilder<?>> consumer) throws IOException {
private static boolean rewriteClauses(QueryRewriteContext queryRewriteContext, List<QueryBuilder> builders,
Consumer<QueryBuilder> consumer) throws IOException {
boolean changed = false;
for (QueryBuilder<?> builder : builders) {
QueryBuilder<?> result = builder.rewrite(queryRewriteContext);
for (QueryBuilder builder : builders) {
QueryBuilder result = builder.rewrite(queryRewriteContext);
if (result != builder) {
changed = true;
}

View File

@ -53,9 +53,9 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder<BoostingQueryBuil
private static final ParseField NEGATIVE_FIELD = new ParseField("negative");
private static final ParseField NEGATIVE_BOOST_FIELD = new ParseField("negative_boost");
private final QueryBuilder<?> positiveQuery;
private final QueryBuilder positiveQuery;
private final QueryBuilder<?> negativeQuery;
private final QueryBuilder negativeQuery;
private float negativeBoost = -1;
@ -66,7 +66,7 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder<BoostingQueryBuil
* @param positiveQuery the positive query for this boosting query.
* @param negativeQuery the negative query for this boosting query.
*/
public BoostingQueryBuilder(QueryBuilder<?> positiveQuery, QueryBuilder<?> negativeQuery) {
public BoostingQueryBuilder(QueryBuilder positiveQuery, QueryBuilder negativeQuery) {
if (positiveQuery == null) {
throw new IllegalArgumentException("inner clause [positive] cannot be null.");
}
@ -226,7 +226,7 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder<BoostingQueryBuil
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder positiveQuery = this.positiveQuery.rewrite(queryRewriteContext);
QueryBuilder negativeQuery = this.negativeQuery.rewrite(queryRewriteContext);
if (positiveQuery != this.positiveQuery || negativeQuery != this.negativeQuery) {

View File

@ -43,7 +43,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder<ConstantScor
private static final ParseField INNER_QUERY_FIELD = new ParseField("filter", "query");
private final QueryBuilder<?> filterBuilder;
private final QueryBuilder filterBuilder;
/**
* A query that wraps another query and simply returns a constant score equal to the
@ -51,7 +51,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder<ConstantScor
*
* @param filterBuilder The query to wrap in a constant score query
*/
public ConstantScoreQueryBuilder(QueryBuilder<?> filterBuilder) {
public ConstantScoreQueryBuilder(QueryBuilder filterBuilder) {
if (filterBuilder == null) {
throw new IllegalArgumentException("inner clause [filter] cannot be null.");
}
@ -74,7 +74,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder<ConstantScor
/**
* @return the query that was wrapped in this constant score query
*/
public QueryBuilder<?> innerQuery() {
public QueryBuilder innerQuery() {
return this.filterBuilder;
}
@ -90,7 +90,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder<ConstantScor
public static ConstantScoreQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
XContentParser parser = parseContext.parser();
QueryBuilder<?> query = null;
QueryBuilder query = null;
boolean queryFound = false;
String queryName = null;
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
@ -163,8 +163,8 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder<ConstantScor
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder<?> rewrite = filterBuilder.rewrite(queryRewriteContext);
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder rewrite = filterBuilder.rewrite(queryRewriteContext);
if (rewrite != filterBuilder) {
return new ConstantScoreQueryBuilder(rewrite);
}

View File

@ -50,7 +50,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
private static final ParseField TIE_BREAKER_FIELD = new ParseField("tie_breaker");
private static final ParseField QUERIES_FIELD = new ParseField("queries");
private final List<QueryBuilder<?>> queries = new ArrayList<>();
private final List<QueryBuilder> queries = new ArrayList<>();
private float tieBreaker = DEFAULT_TIE_BREAKER;
@ -75,7 +75,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
/**
* Add a sub-query to this disjunction.
*/
public DisMaxQueryBuilder add(QueryBuilder<?> queryBuilder) {
public DisMaxQueryBuilder add(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner dismax query clause cannot be null");
}
@ -86,7 +86,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
/**
* @return an immutable list copy of the current sub-queries of this disjunction
*/
public List<QueryBuilder<?>> innerQueries() {
public List<QueryBuilder> innerQueries() {
return this.queries;
}
@ -114,7 +114,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
builder.startObject(NAME);
builder.field(TIE_BREAKER_FIELD.getPreferredName(), tieBreaker);
builder.startArray(QUERIES_FIELD.getPreferredName());
for (QueryBuilder<?> queryBuilder : queries) {
for (QueryBuilder queryBuilder : queries) {
queryBuilder.toXContent(builder, params);
}
builder.endArray();
@ -128,7 +128,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
float tieBreaker = DisMaxQueryBuilder.DEFAULT_TIE_BREAKER;
final List<QueryBuilder<?>> queries = new ArrayList<>();
final List<QueryBuilder> queries = new ArrayList<>();
boolean queriesFound = false;
String queryName = null;
@ -140,7 +140,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
queriesFound = true;
QueryBuilder<?> query = parseContext.parseInnerQueryBuilder();
QueryBuilder query = parseContext.parseInnerQueryBuilder();
queries.add(query);
} else {
throw new ParsingException(parser.getTokenLocation(), "[dis_max] query does not support [" + currentFieldName + "]");
@ -149,7 +149,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
if (parseContext.getParseFieldMatcher().match(currentFieldName, QUERIES_FIELD)) {
queriesFound = true;
while (token != XContentParser.Token.END_ARRAY) {
QueryBuilder<?> query = parseContext.parseInnerQueryBuilder();
QueryBuilder query = parseContext.parseInnerQueryBuilder();
queries.add(query);
token = parser.nextToken();
}
@ -177,7 +177,7 @@ public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
disMaxQuery.tieBreaker(tieBreaker);
disMaxQuery.queryName(queryName);
disMaxQuery.boost(boost);
for (QueryBuilder<?> query : queries) {
for (QueryBuilder query : queries) {
disMaxQuery.add(query);
}
return disMaxQuery;

View File

@ -35,7 +35,7 @@ import java.io.IOException;
import java.util.Objects;
public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder<FieldMaskingSpanQueryBuilder>
implements SpanQueryBuilder<FieldMaskingSpanQueryBuilder>{
implements SpanQueryBuilder {
public static final String NAME = "field_masking_span";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
@ -43,7 +43,7 @@ public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder<FieldMask
private static final ParseField FIELD_FIELD = new ParseField("field");
private static final ParseField QUERY_FIELD = new ParseField("query");
private final SpanQueryBuilder<?> queryBuilder;
private final SpanQueryBuilder queryBuilder;
private final String fieldName;
@ -53,7 +53,7 @@ public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder<FieldMask
* @param queryBuilder inner {@link SpanQueryBuilder}
* @param fieldName the field name
*/
public FieldMaskingSpanQueryBuilder(SpanQueryBuilder<?> queryBuilder, String fieldName) {
public FieldMaskingSpanQueryBuilder(SpanQueryBuilder queryBuilder, String fieldName) {
if (Strings.isEmpty(fieldName)) {
throw new IllegalArgumentException("field name is null or empty");
}
@ -69,7 +69,7 @@ public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder<FieldMask
*/
public FieldMaskingSpanQueryBuilder(StreamInput in) throws IOException {
super(in);
queryBuilder = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
queryBuilder = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
fieldName = in.readString();
}

View File

@ -45,7 +45,7 @@ import java.util.Objects;
* a match query with the fuzziness parameter for strings or range queries for numeric and date fields.
*/
@Deprecated
public class FuzzyQueryBuilder extends AbstractQueryBuilder<FuzzyQueryBuilder> implements MultiTermQueryBuilder<FuzzyQueryBuilder> {
public class FuzzyQueryBuilder extends AbstractQueryBuilder<FuzzyQueryBuilder> implements MultiTermQueryBuilder {
public static final String NAME = "fuzzy";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);

View File

@ -587,7 +587,7 @@ public class GeoShapeQueryBuilder extends AbstractQueryBuilder<GeoShapeQueryBuil
}
@Override
protected QueryBuilder<GeoShapeQueryBuilder> doRewrite(QueryRewriteContext queryShardContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
if (this.shape == null) {
GetRequest getRequest = new GetRequest(indexedShapeIndex, indexedShapeType, indexedShapeId);
ShapeBuilder shape = fetch(queryShardContext.getClient(), getRequest, indexedShapePath);

View File

@ -77,7 +77,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
private static final ParseField INNER_HITS_FIELD = new ParseField("inner_hits");
private static final ParseField IGNORE_UNMAPPED_FIELD = new ParseField("ignore_unmapped");
private final QueryBuilder<?> query;
private final QueryBuilder query;
private final String type;
private final ScoreMode scoreMode;
private InnerHitBuilder innerHitBuilder;
@ -85,11 +85,11 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
private int maxChildren = DEFAULT_MAX_CHILDREN;
private boolean ignoreUnmapped = false;
public HasChildQueryBuilder(String type, QueryBuilder<?> query, ScoreMode scoreMode) {
public HasChildQueryBuilder(String type, QueryBuilder query, ScoreMode scoreMode) {
this(type, query, DEFAULT_MIN_CHILDREN, DEFAULT_MAX_CHILDREN, scoreMode, null);
}
private HasChildQueryBuilder(String type, QueryBuilder<?> query, int minChildren, int maxChildren, ScoreMode scoreMode,
private HasChildQueryBuilder(String type, QueryBuilder query, int minChildren, int maxChildren, ScoreMode scoreMode,
InnerHitBuilder innerHitBuilder) {
this.type = requireValue(type, "[" + NAME + "] requires 'type' field");
this.query = requireValue(query, "[" + NAME + "] requires 'query' field");
@ -158,7 +158,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
/**
* Returns the children query to execute.
*/
public QueryBuilder<?> query() {
public QueryBuilder query() {
return query;
}
@ -238,7 +238,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
InnerHitBuilder innerHitBuilder = null;
String currentFieldName = null;
XContentParser.Token token;
QueryBuilder<?> iqb = null;
QueryBuilder iqb = null;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
@ -467,8 +467,8 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder<?> rewrite = query.rewrite(queryRewriteContext);
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder rewrite = query.rewrite(queryRewriteContext);
if (rewrite != query) {
return new HasChildQueryBuilder(type, rewrite, minChildren, minChildren, scoreMode, innerHitBuilder);
}

View File

@ -60,17 +60,17 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
private static final ParseField INNER_HITS_FIELD = new ParseField("inner_hits");
private static final ParseField IGNORE_UNMAPPED_FIELD = new ParseField("ignore_unmapped");
private final QueryBuilder<?> query;
private final QueryBuilder query;
private final String type;
private final boolean score;
private InnerHitBuilder innerHit;
private boolean ignoreUnmapped = false;
public HasParentQueryBuilder(String type, QueryBuilder<?> query, boolean score) {
public HasParentQueryBuilder(String type, QueryBuilder query, boolean score) {
this(type, query, score, null);
}
private HasParentQueryBuilder(String type, QueryBuilder<?> query, boolean score, InnerHitBuilder innerHit) {
private HasParentQueryBuilder(String type, QueryBuilder query, boolean score, InnerHitBuilder innerHit) {
this.type = requireValue(type, "[" + NAME + "] requires 'type' field");
this.query = requireValue(query, "[" + NAME + "] requires 'query' field");
this.score = score;
@ -101,7 +101,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
/**
* Returns the query to execute.
*/
public QueryBuilder<?> query() {
public QueryBuilder query() {
return query;
}
@ -238,7 +238,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
String currentFieldName = null;
XContentParser.Token token;
QueryBuilder<?> iqb = null;
QueryBuilder iqb = null;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
@ -306,8 +306,8 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryShardContext) throws IOException {
QueryBuilder<?> rewrite = query.rewrite(queryShardContext);
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
QueryBuilder rewrite = query.rewrite(queryShardContext);
if (rewrite != query) {
return new HasParentQueryBuilder(type, rewrite, score, innerHit);
}

View File

@ -55,17 +55,17 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(IndicesQueryBuilder.class));
private final QueryBuilder<?> innerQuery;
private final QueryBuilder innerQuery;
private final String[] indices;
private QueryBuilder<?> noMatchQuery = defaultNoMatchQuery();
private QueryBuilder noMatchQuery = defaultNoMatchQuery();
/**
* @deprecated instead search on the `_index` field
*/
@Deprecated
public IndicesQueryBuilder(QueryBuilder<?> innerQuery, String... indices) {
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");
@ -94,7 +94,7 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
out.writeNamedWriteable(noMatchQuery);
}
public QueryBuilder<?> innerQuery() {
public QueryBuilder innerQuery() {
return this.innerQuery;
}
@ -105,7 +105,7 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
/**
* Sets the query to use when it executes on an index that does not match the indices provided.
*/
public IndicesQueryBuilder noMatchQuery(QueryBuilder<?> noMatchQuery) {
public IndicesQueryBuilder noMatchQuery(QueryBuilder noMatchQuery) {
if (noMatchQuery == null) {
throw new IllegalArgumentException("noMatch query cannot be null");
}
@ -121,11 +121,11 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
return this;
}
public QueryBuilder<?> noMatchQuery() {
public QueryBuilder noMatchQuery() {
return this.noMatchQuery;
}
private static QueryBuilder<?> defaultNoMatchQuery() {
private static QueryBuilder defaultNoMatchQuery() {
return QueryBuilders.matchAllQuery();
}
@ -144,9 +144,9 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
public static IndicesQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, ParsingException {
XContentParser parser = parseContext.parser();
QueryBuilder<?> innerQuery = null;
QueryBuilder innerQuery = null;
Collection<String> indices = new ArrayList<>();
QueryBuilder<?> noMatchQuery = defaultNoMatchQuery();
QueryBuilder noMatchQuery = defaultNoMatchQuery();
String queryName = null;
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
@ -209,7 +209,7 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
.queryName(queryName);
}
static QueryBuilder<?> parseNoMatchQuery(String type) {
static QueryBuilder parseNoMatchQuery(String type) {
if ("all".equals(type)) {
return QueryBuilders.matchAllQuery();
} else if ("none".equals(type)) {
@ -244,9 +244,9 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryShardContext) throws IOException {
QueryBuilder<?> newInnnerQuery = innerQuery.rewrite(queryShardContext);
QueryBuilder<?> newNoMatchQuery = noMatchQuery.rewrite(queryShardContext);
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
QueryBuilder newInnnerQuery = innerQuery.rewrite(queryShardContext);
QueryBuilder newNoMatchQuery = noMatchQuery.rewrite(queryShardContext);
if (newInnnerQuery != innerQuery || newNoMatchQuery != noMatchQuery) {
return new IndicesQueryBuilder(innerQuery, indices).noMatchQuery(noMatchQuery);
}

View File

@ -131,7 +131,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
private boolean trackScores;
private List<String> fieldNames;
private QueryBuilder<?> query = new MatchAllQueryBuilder();
private QueryBuilder query = new MatchAllQueryBuilder();
private List<SortBuilder<?>> sorts;
private List<String> fieldDataFields;
private Set<ScriptField> scriptFields;
@ -411,7 +411,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
return this;
}
QueryBuilder<?> getQuery() {
QueryBuilder getQuery() {
return query;
}
@ -632,7 +632,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
return PARSER.parse(context.parser(), new InnerHitBuilder(), context);
}
public static void extractInnerHits(QueryBuilder<?> query, Map<String, InnerHitBuilder> innerHitBuilders) {
public static void extractInnerHits(QueryBuilder query, Map<String, InnerHitBuilder> innerHitBuilders) {
if (query instanceof AbstractQueryBuilder) {
((AbstractQueryBuilder) query).extractInnerHitBuilders(innerHitBuilders);
} else {

View File

@ -57,7 +57,6 @@ import org.elasticsearch.index.mapper.core.KeywordFieldMapper.KeywordFieldType;
import org.elasticsearch.index.mapper.core.StringFieldMapper.StringFieldType;
import org.elasticsearch.index.mapper.core.TextFieldMapper.TextFieldType;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
import java.util.ArrayList;
@ -1197,7 +1196,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
// TODO this needs heavy cleanups before we can rewrite it
return this;
}

View File

@ -18,6 +18,6 @@
*/
package org.elasticsearch.index.query;
public interface MultiTermQueryBuilder<QB extends MultiTermQueryBuilder<QB>> extends QueryBuilder<QB> {
public interface MultiTermQueryBuilder extends QueryBuilder {
}

View File

@ -57,7 +57,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
private final String path;
private final ScoreMode scoreMode;
private final QueryBuilder<?> query;
private final QueryBuilder query;
private InnerHitBuilder innerHitBuilder;
private boolean ignoreUnmapped = DEFAULT_IGNORE_UNMAPPED;
@ -161,7 +161,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
ScoreMode scoreMode = ScoreMode.Avg;
String queryName = null;
QueryBuilder<?> query = null;
QueryBuilder query = null;
String path = null;
String currentFieldName = null;
InnerHitBuilder innerHitBuilder = null;
@ -259,7 +259,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder rewrite = query.rewrite(queryRewriteContext);
if (rewrite != query) {
return new NestedQueryBuilder(path, rewrite, scoreMode, innerHitBuilder);

View File

@ -327,7 +327,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryShardContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
if (document != null) {
return this;
}

View File

@ -40,7 +40,7 @@ import java.util.Objects;
/**
* A Query that matches documents containing terms with a specified prefix.
*/
public class PrefixQueryBuilder extends AbstractQueryBuilder<PrefixQueryBuilder> implements MultiTermQueryBuilder<PrefixQueryBuilder> {
public class PrefixQueryBuilder extends AbstractQueryBuilder<PrefixQueryBuilder> implements MultiTermQueryBuilder {
public static final String NAME = "prefix";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);

View File

@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
import java.io.IOException;
public interface QueryBuilder<QB extends QueryBuilder<QB>> extends NamedWriteable, ToXContent {
public interface QueryBuilder extends NamedWriteable, ToXContent {
/**
* Converts this QueryBuilder to a lucene {@link Query}.
@ -49,8 +49,11 @@ public interface QueryBuilder<QB extends QueryBuilder<QB>> extends NamedWriteabl
/**
* Sets the arbitrary name to be assigned to the query (see named queries).
* Implementers should return the concrete type of the
* {@link QueryBuilder} so that calls can be chained. This is done
* automatically when extending {@link AbstractQueryBuilder}.
*/
QB queryName(String queryName);
QueryBuilder queryName(String queryName);
/**
* Returns the arbitrary name assigned to the query (see named queries).
@ -65,8 +68,11 @@ public interface QueryBuilder<QB extends QueryBuilder<QB>> extends NamedWriteabl
/**
* Sets the boost for this query. Documents matching this query will (in addition to the normal
* weightings) have their score multiplied by the boost provided.
* Implementers should return the concrete type of the
* {@link QueryBuilder} so that calls can be chained. This is done
* automatically when extending {@link AbstractQueryBuilder}.
*/
QB boost(float boost);
QueryBuilder boost(float boost);
/**
* Returns the name that identifies uniquely the query
@ -77,7 +83,7 @@ public interface QueryBuilder<QB extends QueryBuilder<QB>> extends NamedWriteabl
* Rewrites this query builder into its primitive form. By default this method return the builder itself. If the builder
* did not change the identity reference must be returned otherwise the builder will be rewritten infinitely.
*/
default QueryBuilder<?> rewrite(QueryRewriteContext queryShardContext) throws IOException {
default QueryBuilder rewrite(QueryRewriteContext queryShardContext) throws IOException {
return this;
}
@ -87,7 +93,7 @@ public interface QueryBuilder<QB extends QueryBuilder<QB>> extends NamedWriteabl
* rewrites the query until it doesn't change anymore.
* @throws IOException if an {@link IOException} occurs
*/
static QueryBuilder<?> rewriteQuery(QueryBuilder<?> original, QueryRewriteContext context) throws IOException {
static QueryBuilder rewriteQuery(QueryBuilder original, QueryRewriteContext context) throws IOException {
QueryBuilder builder = original;
for (QueryBuilder rewrittenBuilder = builder.rewrite(context); rewrittenBuilder != builder;
rewrittenBuilder = builder.rewrite(context)) {

View File

@ -55,9 +55,9 @@ public class QueryParseContext implements ParseFieldMatcherSupplier {
/**
* Parses a top level query including the query element that wraps it
*/
public QueryBuilder<?> parseTopLevelQueryBuilder() {
public QueryBuilder parseTopLevelQueryBuilder() {
try {
QueryBuilder<?> queryBuilder = null;
QueryBuilder queryBuilder = null;
for (XContentParser.Token token = parser.nextToken(); token != XContentParser.Token.END_OBJECT; token = parser.nextToken()) {
if (token == XContentParser.Token.FIELD_NAME) {
String fieldName = parser.currentName();
@ -82,7 +82,7 @@ public class QueryParseContext implements ParseFieldMatcherSupplier {
/**
* Parses a query excluding the query element that wraps it
*/
public QueryBuilder<?> parseInnerQueryBuilder() throws IOException {
public QueryBuilder parseInnerQueryBuilder() throws IOException {
// move to START object
XContentParser.Token token;
if (parser.currentToken() != XContentParser.Token.START_OBJECT) {
@ -105,7 +105,7 @@ public class QueryParseContext implements ParseFieldMatcherSupplier {
if (token != XContentParser.Token.START_OBJECT && token != XContentParser.Token.START_ARRAY) {
throw new ParsingException(parser.getTokenLocation(), "[_na] query malformed, no field after start_object");
}
QueryBuilder<?> result = indicesQueriesRegistry.lookup(queryName, parseFieldMatcher, parser.getTokenLocation()).fromXContent(this);
QueryBuilder result = indicesQueriesRegistry.lookup(queryName, parseFieldMatcher, parser.getTokenLocation()).fromXContent(this);
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();

View File

@ -25,7 +25,7 @@ import java.io.IOException;
* Defines a query parser that is able to parse {@link QueryBuilder}s from {@link org.elasticsearch.common.xcontent.XContent}.
*/
@FunctionalInterface
public interface QueryParser<QB extends QueryBuilder<QB>> {
public interface QueryParser<QB extends QueryBuilder> {
/**
* Creates a new {@link QueryBuilder} from the query held by the {@link QueryParseContext}
* in {@link org.elasticsearch.common.xcontent.XContent} format

View File

@ -46,7 +46,7 @@ import java.util.Objects;
/**
* A Query that matches documents within an range of terms.
*/
public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> implements MultiTermQueryBuilder<RangeQueryBuilder> {
public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> implements MultiTermQueryBuilder {
public static final String NAME = "range";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
@ -410,7 +410,7 @@ public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> i
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
final MappedFieldType.Relation relation = getRelation(queryRewriteContext);
switch (relation) {
case DISJOINT:

View File

@ -41,7 +41,7 @@ import java.util.Objects;
/**
* A Query that does fuzzy matching for a specific value.
*/
public class RegexpQueryBuilder extends AbstractQueryBuilder<RegexpQueryBuilder> implements MultiTermQueryBuilder<RegexpQueryBuilder> {
public class RegexpQueryBuilder extends AbstractQueryBuilder<RegexpQueryBuilder> implements MultiTermQueryBuilder {
public static final String NAME = "regexp";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);

View File

@ -36,7 +36,7 @@ import java.util.Objects;
* Builder for {@link org.apache.lucene.search.spans.SpanContainingQuery}.
*/
public class SpanContainingQueryBuilder extends AbstractQueryBuilder<SpanContainingQueryBuilder>
implements SpanQueryBuilder<SpanContainingQueryBuilder> {
implements SpanQueryBuilder {
public static final String NAME = "span_containing";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
@ -44,14 +44,14 @@ public class SpanContainingQueryBuilder extends AbstractQueryBuilder<SpanContain
private static final ParseField BIG_FIELD = new ParseField("big");
private static final ParseField LITTLE_FIELD = new ParseField("little");
private final SpanQueryBuilder<?> big;
private final SpanQueryBuilder<?> little;
private final SpanQueryBuilder big;
private final SpanQueryBuilder little;
/**
* @param big the big clause, it must enclose {@code little} for a match.
* @param little the little clause, it must be contained within {@code big} for a match.
*/
public SpanContainingQueryBuilder(SpanQueryBuilder<?> big, SpanQueryBuilder<?> little) {
public SpanContainingQueryBuilder(SpanQueryBuilder big, SpanQueryBuilder little) {
if (big == null) {
throw new IllegalArgumentException("inner clause [big] cannot be null.");
}
@ -67,8 +67,8 @@ public class SpanContainingQueryBuilder extends AbstractQueryBuilder<SpanContain
*/
public SpanContainingQueryBuilder(StreamInput in) throws IOException {
super(in);
big = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
little = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
big = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
little = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
}
@Override
@ -106,8 +106,8 @@ public class SpanContainingQueryBuilder extends AbstractQueryBuilder<SpanContain
XContentParser parser = parseContext.parser();
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String queryName = null;
SpanQueryBuilder<?> big = null;
SpanQueryBuilder<?> little = null;
SpanQueryBuilder big = null;
SpanQueryBuilder little = null;
String currentFieldName = null;
XContentParser.Token token;
@ -117,16 +117,16 @@ public class SpanContainingQueryBuilder extends AbstractQueryBuilder<SpanContain
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.getParseFieldMatcher().match(currentFieldName, BIG_FIELD)) {
QueryBuilder query = parseContext.parseInnerQueryBuilder();
if (!(query instanceof SpanQueryBuilder<?>)) {
if (!(query instanceof SpanQueryBuilder)) {
throw new ParsingException(parser.getTokenLocation(), "span_containing [big] must be of type span query");
}
big = (SpanQueryBuilder<?>) query;
big = (SpanQueryBuilder) query;
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, LITTLE_FIELD)) {
QueryBuilder query = parseContext.parseInnerQueryBuilder();
if (!(query instanceof SpanQueryBuilder<?>)) {
if (!(query instanceof SpanQueryBuilder)) {
throw new ParsingException(parser.getTokenLocation(), "span_containing [little] must be of type span query");
}
little = (SpanQueryBuilder<?>) query;
little = (SpanQueryBuilder) query;
} else {
throw new ParsingException(parser.getTokenLocation(),
"[span_containing] query does not support [" + currentFieldName + "]");

View File

@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.Objects;
public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBuilder> implements SpanQueryBuilder<SpanFirstQueryBuilder>{
public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBuilder> implements SpanQueryBuilder {
public static final String NAME = "span_first";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
@ -40,7 +40,7 @@ public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBu
private static final ParseField MATCH_FIELD = new ParseField("match");
private static final ParseField END_FIELD = new ParseField("end");
private final SpanQueryBuilder<?> matchBuilder;
private final SpanQueryBuilder matchBuilder;
private final int end;
@ -51,7 +51,7 @@ public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBu
* @param end maximum end position of the match, needs to be positive
* @throws IllegalArgumentException for negative <code>end</code> positions
*/
public SpanFirstQueryBuilder(SpanQueryBuilder<?> matchBuilder, int end) {
public SpanFirstQueryBuilder(SpanQueryBuilder matchBuilder, int end) {
if (matchBuilder == null) {
throw new IllegalArgumentException("inner span query cannot be null");
}
@ -67,7 +67,7 @@ public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBu
*/
public SpanFirstQueryBuilder(StreamInput in) throws IOException {
super(in);
matchBuilder = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
matchBuilder = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
end = in.readInt();
}
@ -80,7 +80,7 @@ public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBu
/**
* @return the inner {@link SpanQueryBuilder} defined in this query
*/
public SpanQueryBuilder<?> innerQuery() {
public SpanQueryBuilder innerQuery() {
return this.matchBuilder;
}

View File

@ -39,16 +39,16 @@ import java.util.Objects;
* as a {@link SpanQueryBuilder} so it can be nested.
*/
public class SpanMultiTermQueryBuilder extends AbstractQueryBuilder<SpanMultiTermQueryBuilder>
implements SpanQueryBuilder<SpanMultiTermQueryBuilder> {
implements SpanQueryBuilder {
public static final String NAME = "span_multi";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
private static final ParseField MATCH_FIELD = new ParseField("match");
private final MultiTermQueryBuilder<?> multiTermQueryBuilder;
private final MultiTermQueryBuilder multiTermQueryBuilder;
public SpanMultiTermQueryBuilder(MultiTermQueryBuilder<?> multiTermQueryBuilder) {
public SpanMultiTermQueryBuilder(MultiTermQueryBuilder multiTermQueryBuilder) {
if (multiTermQueryBuilder == null) {
throw new IllegalArgumentException("inner multi term query cannot be null");
}
@ -60,7 +60,7 @@ public class SpanMultiTermQueryBuilder extends AbstractQueryBuilder<SpanMultiTer
*/
public SpanMultiTermQueryBuilder(StreamInput in) throws IOException {
super(in);
multiTermQueryBuilder = (MultiTermQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
multiTermQueryBuilder = (MultiTermQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
}
@Override
@ -68,7 +68,7 @@ public class SpanMultiTermQueryBuilder extends AbstractQueryBuilder<SpanMultiTer
out.writeNamedWriteable(multiTermQueryBuilder);
}
public MultiTermQueryBuilder<?> innerQuery() {
public MultiTermQueryBuilder innerQuery() {
return this.multiTermQueryBuilder;
}

View File

@ -39,7 +39,7 @@ import java.util.Objects;
* of intervening unmatched positions, as well as whether matches are required to be in-order.
* The span near query maps to Lucene {@link SpanNearQuery}.
*/
public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuilder> implements SpanQueryBuilder<SpanNearQueryBuilder> {
public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuilder> implements SpanQueryBuilder {
public static final String NAME = "span_near";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
@ -52,7 +52,7 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
private static final ParseField CLAUSES_FIELD = new ParseField("clauses");
private static final ParseField IN_ORDER_FIELD = new ParseField("in_order");
private final List<SpanQueryBuilder<?>> clauses = new ArrayList<>();
private final List<SpanQueryBuilder> clauses = new ArrayList<>();
private final int slop;
@ -62,7 +62,7 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
* @param initialClause an initial span query clause
* @param slop controls the maximum number of intervening unmatched positions permitted
*/
public SpanNearQueryBuilder(SpanQueryBuilder<?> initialClause, int slop) {
public SpanNearQueryBuilder(SpanQueryBuilder initialClause, int slop) {
if (initialClause == null) {
throw new IllegalArgumentException("query must include at least one clause");
}
@ -75,8 +75,8 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
*/
public SpanNearQueryBuilder(StreamInput in) throws IOException {
super(in);
for (QueryBuilder<?> clause : readQueries(in)) {
this.clauses.add((SpanQueryBuilder<?>) clause);
for (QueryBuilder clause : readQueries(in)) {
this.clauses.add((SpanQueryBuilder) clause);
}
slop = in.readVInt();
inOrder = in.readBoolean();
@ -96,7 +96,7 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
return this.slop;
}
public SpanNearQueryBuilder clause(SpanQueryBuilder<?> clause) {
public SpanNearQueryBuilder clause(SpanQueryBuilder clause) {
if (clause == null) {
throw new IllegalArgumentException("query clauses cannot be null");
}
@ -107,7 +107,7 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
/**
* @return the {@link SpanQueryBuilder} clauses that were set for this query
*/
public List<SpanQueryBuilder<?>> clauses() {
public List<SpanQueryBuilder> clauses() {
return this.clauses;
}
@ -132,7 +132,7 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(NAME);
builder.startArray(CLAUSES_FIELD.getPreferredName());
for (SpanQueryBuilder<?> clause : clauses) {
for (SpanQueryBuilder clause : clauses) {
clause.toXContent(builder, params);
}
builder.endArray();

View File

@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.Objects;
public class SpanNotQueryBuilder extends AbstractQueryBuilder<SpanNotQueryBuilder> implements SpanQueryBuilder<SpanNotQueryBuilder> {
public class SpanNotQueryBuilder extends AbstractQueryBuilder<SpanNotQueryBuilder> implements SpanQueryBuilder {
public static final String NAME = "span_not";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
@ -48,9 +48,9 @@ public class SpanNotQueryBuilder extends AbstractQueryBuilder<SpanNotQueryBuilde
private static final ParseField EXCLUDE_FIELD = new ParseField("exclude");
private static final ParseField INCLUDE_FIELD = new ParseField("include");
private final SpanQueryBuilder<?> include;
private final SpanQueryBuilder include;
private final SpanQueryBuilder<?> exclude;
private final SpanQueryBuilder exclude;
private int pre = DEFAULT_PRE;
@ -62,7 +62,7 @@ public class SpanNotQueryBuilder extends AbstractQueryBuilder<SpanNotQueryBuilde
* @param include the span query whose matches are filtered
* @param exclude the span query whose matches must not overlap
*/
public SpanNotQueryBuilder(SpanQueryBuilder<?> include, SpanQueryBuilder<?> exclude) {
public SpanNotQueryBuilder(SpanQueryBuilder include, SpanQueryBuilder exclude) {
if (include == null) {
throw new IllegalArgumentException("inner clause [include] cannot be null.");
}
@ -78,8 +78,8 @@ public class SpanNotQueryBuilder extends AbstractQueryBuilder<SpanNotQueryBuilde
*/
public SpanNotQueryBuilder(StreamInput in) throws IOException {
super(in);
include = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
exclude = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
include = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
exclude = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
pre = in.readVInt();
post = in.readVInt();
}

View File

@ -37,16 +37,16 @@ import java.util.Objects;
/**
* Span query that matches the union of its clauses. Maps to {@link SpanOrQuery}.
*/
public class SpanOrQueryBuilder extends AbstractQueryBuilder<SpanOrQueryBuilder> implements SpanQueryBuilder<SpanOrQueryBuilder> {
public class SpanOrQueryBuilder extends AbstractQueryBuilder<SpanOrQueryBuilder> implements SpanQueryBuilder {
public static final String NAME = "span_or";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
private static final ParseField CLAUSES_FIELD = new ParseField("clauses");
private final List<SpanQueryBuilder<?>> clauses = new ArrayList<>();
private final List<SpanQueryBuilder> clauses = new ArrayList<>();
public SpanOrQueryBuilder(SpanQueryBuilder<?> initialClause) {
public SpanOrQueryBuilder(SpanQueryBuilder initialClause) {
if (initialClause == null) {
throw new IllegalArgumentException("query must include at least one clause");
}
@ -58,8 +58,8 @@ public class SpanOrQueryBuilder extends AbstractQueryBuilder<SpanOrQueryBuilder>
*/
public SpanOrQueryBuilder(StreamInput in) throws IOException {
super(in);
for (QueryBuilder<?> clause: readQueries(in)) {
clauses.add((SpanQueryBuilder<?>) clause);
for (QueryBuilder clause: readQueries(in)) {
clauses.add((SpanQueryBuilder) clause);
}
}
@ -68,7 +68,7 @@ public class SpanOrQueryBuilder extends AbstractQueryBuilder<SpanOrQueryBuilder>
writeQueries(out, clauses);
}
public SpanOrQueryBuilder clause(SpanQueryBuilder<?> clause) {
public SpanOrQueryBuilder clause(SpanQueryBuilder clause) {
if (clause == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@ -79,7 +79,7 @@ public class SpanOrQueryBuilder extends AbstractQueryBuilder<SpanOrQueryBuilder>
/**
* @return the {@link SpanQueryBuilder} clauses that were set for this query
*/
public List<SpanQueryBuilder<?>> clauses() {
public List<SpanQueryBuilder> clauses() {
return this.clauses;
}
@ -87,7 +87,7 @@ public class SpanOrQueryBuilder extends AbstractQueryBuilder<SpanOrQueryBuilder>
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(NAME);
builder.startArray(CLAUSES_FIELD.getPreferredName());
for (SpanQueryBuilder<?> clause : clauses) {
for (SpanQueryBuilder clause : clauses) {
clause.toXContent(builder, params);
}
builder.endArray();

View File

@ -22,6 +22,6 @@ package org.elasticsearch.index.query;
/**
* Marker interface for a specific type of {@link QueryBuilder} that allows to build span queries
*/
public interface SpanQueryBuilder<QB extends SpanQueryBuilder<QB>> extends QueryBuilder<QB> {
public interface SpanQueryBuilder extends QueryBuilder {
}

View File

@ -36,7 +36,7 @@ import java.io.IOException;
* A Span Query that matches documents containing a term.
* @see SpanTermQuery
*/
public class SpanTermQueryBuilder extends BaseTermQueryBuilder<SpanTermQueryBuilder> implements SpanQueryBuilder<SpanTermQueryBuilder> {
public class SpanTermQueryBuilder extends BaseTermQueryBuilder<SpanTermQueryBuilder> implements SpanQueryBuilder {
public static final String NAME = "span_term";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);

View File

@ -36,7 +36,7 @@ import java.util.Objects;
* Builder for {@link org.apache.lucene.search.spans.SpanWithinQuery}.
*/
public class SpanWithinQueryBuilder extends AbstractQueryBuilder<SpanWithinQueryBuilder>
implements SpanQueryBuilder<SpanWithinQueryBuilder> {
implements SpanQueryBuilder {
public static final String NAME = "span_within";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);
@ -44,15 +44,15 @@ public class SpanWithinQueryBuilder extends AbstractQueryBuilder<SpanWithinQuery
private static final ParseField BIG_FIELD = new ParseField("big");
private static final ParseField LITTLE_FIELD = new ParseField("little");
private final SpanQueryBuilder<?> big;
private final SpanQueryBuilder<?> little;
private final SpanQueryBuilder big;
private final SpanQueryBuilder little;
/**
* Query that returns spans from <code>little</code> that are contained in a spans from <code>big</code>.
* @param big clause that must enclose {@code little} for a match.
* @param little the little clause, it must be contained within {@code big} for a match.
*/
public SpanWithinQueryBuilder(SpanQueryBuilder<?> big, SpanQueryBuilder<?> little) {
public SpanWithinQueryBuilder(SpanQueryBuilder big, SpanQueryBuilder little) {
if (big == null) {
throw new IllegalArgumentException("inner clause [big] cannot be null.");
}
@ -68,8 +68,8 @@ public class SpanWithinQueryBuilder extends AbstractQueryBuilder<SpanWithinQuery
*/
public SpanWithinQueryBuilder(StreamInput in) throws IOException {
super(in);
big = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
little = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
big = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
little = (SpanQueryBuilder) in.readNamedWriteable(QueryBuilder.class);
}
@Override

View File

@ -173,13 +173,13 @@ public class TemplateQueryBuilder extends AbstractQueryBuilder<TemplateQueryBuil
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
ExecutableScript executable = queryRewriteContext.getScriptService().executable(template,
ScriptContext.Standard.SEARCH, Collections.emptyMap(), queryRewriteContext.getClusterState());
BytesReference querySource = (BytesReference) executable.run();
try (XContentParser qSourceParser = XContentFactory.xContent(querySource).createParser(querySource)) {
final QueryParseContext queryParseContext = queryRewriteContext.newParseContext(qSourceParser);
final QueryBuilder<?> queryBuilder = queryParseContext.parseInnerQueryBuilder();
final QueryBuilder queryBuilder = queryParseContext.parseInnerQueryBuilder();
if (boost() != DEFAULT_BOOST || queryName() != null) {
final BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
boolQueryBuilder.must(queryBuilder);

View File

@ -381,7 +381,7 @@ public class TermsQueryBuilder extends AbstractQueryBuilder<TermsQueryBuilder> {
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
if (this.termsLookup != null) {
TermsLookup termsLookup = new TermsLookup(this.termsLookup);
if (termsLookup.index() == null) { // TODO this should go away?

View File

@ -46,7 +46,7 @@ import java.util.Objects;
* <tt>?</tt>.
*/
public class WildcardQueryBuilder extends AbstractQueryBuilder<WildcardQueryBuilder>
implements MultiTermQueryBuilder<WildcardQueryBuilder> {
implements MultiTermQueryBuilder {
public static final String NAME = "wildcard";
public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME);

View File

@ -160,11 +160,11 @@ public class WrapperQueryBuilder extends AbstractQueryBuilder<WrapperQueryBuilde
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext context) throws IOException {
protected QueryBuilder doRewrite(QueryRewriteContext context) throws IOException {
try (XContentParser qSourceParser = XContentFactory.xContent(source).createParser(source)) {
QueryParseContext parseContext = context.newParseContext(qSourceParser);
final QueryBuilder<?> queryBuilder = parseContext.parseInnerQueryBuilder();
final QueryBuilder queryBuilder = parseContext.parseInnerQueryBuilder();
if (boost() != DEFAULT_BOOST || queryName() != null) {
final BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
boolQueryBuilder.must(queryBuilder);

View File

@ -75,7 +75,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
public static final CombineFunction DEFAULT_BOOST_MODE = CombineFunction.MULTIPLY;
public static final FiltersFunctionScoreQuery.ScoreMode DEFAULT_SCORE_MODE = FiltersFunctionScoreQuery.ScoreMode.MULTIPLY;
private final QueryBuilder<?> query;
private final QueryBuilder query;
private float maxBoost = FunctionScoreQuery.DEFAULT_MAX_BOOST;
@ -92,7 +92,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
*
* @param query the query that needs to be custom scored
*/
public FunctionScoreQueryBuilder(QueryBuilder<?> query) {
public FunctionScoreQueryBuilder(QueryBuilder query) {
this(query, new FilterFunctionBuilder[0]);
}
@ -120,7 +120,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
* @param query the query to custom score
* @param scoreFunctionBuilder score function that is executed
*/
public FunctionScoreQueryBuilder(QueryBuilder<?> query, ScoreFunctionBuilder<?> scoreFunctionBuilder) {
public FunctionScoreQueryBuilder(QueryBuilder query, ScoreFunctionBuilder<?> scoreFunctionBuilder) {
this(query, new FilterFunctionBuilder[]{new FilterFunctionBuilder(scoreFunctionBuilder)});
}
@ -130,7 +130,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
* @param query the query that defines which documents the function_score query will be executed on.
* @param filterFunctionBuilders the filters and functions
*/
public FunctionScoreQueryBuilder(QueryBuilder<?> query, FilterFunctionBuilder[] filterFunctionBuilders) {
public FunctionScoreQueryBuilder(QueryBuilder query, FilterFunctionBuilder[] filterFunctionBuilders) {
if (query == null) {
throw new IllegalArgumentException("function_score: query must not be null");
}
@ -172,7 +172,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
/**
* Returns the query that defines which documents the function_score query will be executed on.
*/
public QueryBuilder<?> query() {
public QueryBuilder query() {
return this.query;
}
@ -334,14 +334,14 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
* that match the given filter.
*/
public static class FilterFunctionBuilder implements ToXContent, Writeable {
private final QueryBuilder<?> filter;
private final QueryBuilder filter;
private final ScoreFunctionBuilder<?> scoreFunction;
public FilterFunctionBuilder(ScoreFunctionBuilder<?> scoreFunctionBuilder) {
this(new MatchAllQueryBuilder(), scoreFunctionBuilder);
}
public FilterFunctionBuilder(QueryBuilder<?> filter, ScoreFunctionBuilder<?> scoreFunction) {
public FilterFunctionBuilder(QueryBuilder filter, ScoreFunctionBuilder<?> scoreFunction) {
if (filter == null) {
throw new IllegalArgumentException("function_score: filter must not be null");
}
@ -366,7 +366,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
out.writeNamedWriteable(scoreFunction);
}
public QueryBuilder<?> getFilter() {
public QueryBuilder getFilter() {
return filter;
}
@ -403,7 +403,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
}
public FilterFunctionBuilder rewrite(QueryRewriteContext context) throws IOException {
QueryBuilder<?> rewrite = filter.rewrite(context);
QueryBuilder rewrite = filter.rewrite(context);
if (rewrite != filter) {
return new FilterFunctionBuilder(rewrite, scoreFunction);
}
@ -412,8 +412,8 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
}
@Override
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder<?> queryBuilder = this.query.rewrite(queryRewriteContext);
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder queryBuilder = this.query.rewrite(queryRewriteContext);
FilterFunctionBuilder[] rewrittenBuilders = new FilterFunctionBuilder[this.filterFunctionBuilders.length];
boolean rewritten = false;
for (int i = 0; i < rewrittenBuilders.length; i++) {
@ -442,7 +442,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
QueryParseContext parseContext) throws IOException {
XContentParser parser = parseContext.parser();
QueryBuilder<?> query = null;
QueryBuilder query = null;
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String queryName = null;
@ -571,7 +571,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
XContentParser.Token token;
XContentParser parser = parseContext.parser();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
QueryBuilder<?> filter = null;
QueryBuilder filter = null;
ScoreFunctionBuilder<?> scoreFunction = null;
Float functionWeight = null;
if (token != XContentParser.Token.START_OBJECT) {

View File

@ -82,7 +82,7 @@ public class RestValidateQueryAction extends BaseRestHandler {
return;
}
} else {
QueryBuilder<?> queryBuilder = RestActions.urlParamsToQueryBuilder(request);
QueryBuilder queryBuilder = RestActions.urlParamsToQueryBuilder(request);
if (queryBuilder != null) {
validateQueryRequest.query(queryBuilder);
}

View File

@ -68,7 +68,7 @@ public class RestCountAction extends AbstractCatAction {
if (source != null) {
searchSourceBuilder.query(RestActions.getQueryContent(new BytesArray(source), indicesQueriesRegistry, parseFieldMatcher));
} else {
QueryBuilder<?> queryBuilder = RestActions.urlParamsToQueryBuilder(request);
QueryBuilder queryBuilder = RestActions.urlParamsToQueryBuilder(request);
if (queryBuilder != null) {
searchSourceBuilder.query(queryBuilder);
}

View File

@ -74,7 +74,7 @@ public class RestCountAction extends BaseRestHandler {
BytesReference restContent = RestActions.getRestContent(request);
searchSourceBuilder.query(RestActions.getQueryContent(restContent, indicesQueriesRegistry, parseFieldMatcher));
} else {
QueryBuilder<?> queryBuilder = RestActions.urlParamsToQueryBuilder(request);
QueryBuilder queryBuilder = RestActions.urlParamsToQueryBuilder(request);
if (queryBuilder != null) {
searchSourceBuilder.query(queryBuilder);
}

View File

@ -74,7 +74,7 @@ public class RestExplainAction extends BaseRestHandler {
BytesReference restContent = RestActions.getRestContent(request);
explainRequest.query(RestActions.getQueryContent(restContent, indicesQueriesRegistry, parseFieldMatcher));
} else if (queryString != null) {
QueryBuilder<?> query = RestActions.urlParamsToQueryBuilder(request);
QueryBuilder query = RestActions.urlParamsToQueryBuilder(request);
explainRequest.query(query);
}

View File

@ -162,7 +162,7 @@ public class RestSearchAction extends BaseRestHandler {
* values that are not overridden by the rest request.
*/
private static void parseSearchSource(final SearchSourceBuilder searchSourceBuilder, RestRequest request) {
QueryBuilder<?> queryBuilder = RestActions.urlParamsToQueryBuilder(request);
QueryBuilder queryBuilder = RestActions.urlParamsToQueryBuilder(request);
if (queryBuilder != null) {
searchSourceBuilder.query(queryBuilder);
}

View File

@ -93,7 +93,7 @@ public class RestActions {
builder.endObject();
}
public static QueryBuilder<?> urlParamsToQueryBuilder(RestRequest request) {
public static QueryBuilder urlParamsToQueryBuilder(RestRequest request) {
String queryString = request.param("q");
if (queryString == null) {
return null;
@ -130,7 +130,7 @@ public class RestActions {
return content;
}
public static QueryBuilder<?> getQueryContent(BytesReference source, IndicesQueriesRegistry indicesQueriesRegistry, ParseFieldMatcher parseFieldMatcher) {
public static QueryBuilder getQueryContent(BytesReference source, IndicesQueriesRegistry indicesQueriesRegistry, ParseFieldMatcher parseFieldMatcher) {
try (XContentParser requestParser = XContentFactory.xContent(source).createParser(source)) {
QueryParseContext context = new QueryParseContext(indicesQueriesRegistry, requestParser, parseFieldMatcher);
return context.parseTopLevelQueryBuilder();

View File

@ -359,7 +359,7 @@ public class SearchModule extends AbstractModule {
* is the name by under which the reader is registered. So it is the name that the query should use as its
* {@link NamedWriteable#getWriteableName()} too.
*/
public <QB extends QueryBuilder<QB>> void registerQuery(Writeable.Reader<QB> reader, QueryParser<QB> queryParser,
public <QB extends QueryBuilder> void registerQuery(Writeable.Reader<QB> reader, QueryParser<QB> queryParser,
ParseField queryName) {
queryParserRegistry.register(queryParser, queryName);
namedWriteableRegistry.register(QueryBuilder.class, queryName.getPreferredName(), reader);

View File

@ -142,7 +142,7 @@ public class AggregationBuilders {
/**
* Create a new {@link Filter} aggregation with the given name.
*/
public static FilterAggregatorBuilder filter(String name, QueryBuilder<?> filter) {
public static FilterAggregatorBuilder filter(String name, QueryBuilder filter) {
return new FilterAggregatorBuilder(name, filter);
}
@ -156,7 +156,7 @@ public class AggregationBuilders {
/**
* Create a new {@link Filters} aggregation with the given name.
*/
public static FiltersAggregatorBuilder filters(String name, QueryBuilder<?>... filters) {
public static FiltersAggregatorBuilder filters(String name, QueryBuilder... filters) {
return new FiltersAggregatorBuilder(name, filters);
}

View File

@ -41,7 +41,7 @@ public class FilterAggregatorBuilder extends AggregatorBuilder<FilterAggregatorB
public static final String NAME = InternalFilter.TYPE.name();
public static final ParseField AGGREGATION_NAME_FIELD = new ParseField(NAME);
private final QueryBuilder<?> filter;
private final QueryBuilder filter;
/**
* @param name
@ -51,7 +51,7 @@ public class FilterAggregatorBuilder extends AggregatorBuilder<FilterAggregatorB
* filter will fall into the bucket defined by this
* {@link Filter} aggregation.
*/
public FilterAggregatorBuilder(String name, QueryBuilder<?> filter) {
public FilterAggregatorBuilder(String name, QueryBuilder filter) {
super(name, InternalFilter.TYPE);
if (filter == null) {
throw new IllegalArgumentException("[filter] must not be null: [" + name + "]");
@ -92,7 +92,7 @@ public class FilterAggregatorBuilder extends AggregatorBuilder<FilterAggregatorB
public static FilterAggregatorBuilder parse(String aggregationName, QueryParseContext context)
throws IOException {
QueryBuilder<?> filter = context.parseInnerQueryBuilder();
QueryBuilder filter = context.parseInnerQueryBuilder();
if (filter == null) {
throw new ParsingException(null, "filter cannot be null in filter aggregation [{}]", aggregationName);

View File

@ -38,7 +38,7 @@ public class FilterAggregatorFactory extends AggregatorFactory<FilterAggregatorF
private final Weight weight;
public FilterAggregatorFactory(String name, Type type, QueryBuilder<?> filterBuilder, AggregationContext context,
public FilterAggregatorFactory(String name, Type type, QueryBuilder filterBuilder, AggregationContext context,
AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
super(name, type, context, parent, subFactoriesBuilder, metaData);
IndexSearcher contextSearcher = context.searchContext().searcher();

View File

@ -59,9 +59,9 @@ public class FiltersAggregator extends BucketsAggregator {
public static class KeyedFilter implements Writeable, ToXContent {
private final String key;
private final QueryBuilder<?> filter;
private final QueryBuilder filter;
public KeyedFilter(String key, QueryBuilder<?> filter) {
public KeyedFilter(String key, QueryBuilder filter) {
if (key == null) {
throw new IllegalArgumentException("[key] must not be null");
}
@ -94,7 +94,7 @@ public class FiltersAggregator extends BucketsAggregator {
return key;
}
public QueryBuilder<?> filter() {
public QueryBuilder filter() {
return filter;
}

View File

@ -80,7 +80,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
* @param filters
* the filters to use with this aggregation
*/
public FiltersAggregatorBuilder(String name, QueryBuilder<?>... filters) {
public FiltersAggregatorBuilder(String name, QueryBuilder... filters) {
super(name, InternalFilters.TYPE);
List<KeyedFilter> keyedFilters = new ArrayList<>(filters.length);
for (int i = 0; i < filters.length; i++) {
@ -204,7 +204,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
XContentParser parser = context.parser();
List<FiltersAggregator.KeyedFilter> keyedFilters = null;
List<QueryBuilder<?>> nonKeyedFilters = null;
List<QueryBuilder> nonKeyedFilters = null;
XContentParser.Token token = null;
String currentFieldName = null;
@ -235,7 +235,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
if (token == XContentParser.Token.FIELD_NAME) {
key = parser.currentName();
} else {
QueryBuilder<?> filter = context.parseInnerQueryBuilder();
QueryBuilder filter = context.parseInnerQueryBuilder();
keyedFilters.add(new FiltersAggregator.KeyedFilter(key, filter == null ? matchAllQuery() : filter));
}
}
@ -247,7 +247,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
if (context.getParseFieldMatcher().match(currentFieldName, FILTERS_FIELD)) {
nonKeyedFilters = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
QueryBuilder<?> filter = context.parseInnerQueryBuilder();
QueryBuilder filter = context.parseInnerQueryBuilder();
nonKeyedFilters.add(filter == null ? QueryBuilders.matchAllQuery() : filter);
}
} else {
@ -270,7 +270,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
keyedFilters.toArray(new FiltersAggregator.KeyedFilter[keyedFilters.size()]));
} else {
factory = new FiltersAggregatorBuilder(aggregationName,
nonKeyedFilters.toArray(new QueryBuilder<?>[nonKeyedFilters.size()]));
nonKeyedFilters.toArray(new QueryBuilder[nonKeyedFilters.size()]));
}
if (otherBucket != null) {
factory.otherBucket(otherBucket);

View File

@ -58,7 +58,7 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
private IncludeExclude includeExclude = null;
private String executionHint = null;
private QueryBuilder<?> filterBuilder = null;
private QueryBuilder filterBuilder = null;
private TermsAggregator.BucketCountThresholds bucketCountThresholds = new BucketCountThresholds(DEFAULT_BUCKET_COUNT_THRESHOLDS);
private SignificanceHeuristic significanceHeuristic = DEFAULT_SIGNIFICANCE_HEURISTIC;
@ -176,7 +176,7 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
return executionHint;
}
public SignificantTermsAggregatorBuilder backgroundFilter(QueryBuilder<?> backgroundFilter) {
public SignificantTermsAggregatorBuilder backgroundFilter(QueryBuilder backgroundFilter) {
if (backgroundFilter == null) {
throw new IllegalArgumentException("[backgroundFilter] must not be null: [" + name + "]");
}
@ -184,7 +184,7 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
return this;
}
public QueryBuilder<?> backgroundFilter() {
public QueryBuilder backgroundFilter() {
return filterBuilder;
}

View File

@ -65,12 +65,12 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac
private MappedFieldType fieldType;
private FilterableTermsEnum termsEnum;
private int numberOfAggregatorsCreated;
private final QueryBuilder<?> filterBuilder;
private final QueryBuilder filterBuilder;
private final TermsAggregator.BucketCountThresholds bucketCountThresholds;
private final SignificanceHeuristic significanceHeuristic;
public SignificantTermsAggregatorFactory(String name, Type type, ValuesSourceConfig<ValuesSource> config, IncludeExclude includeExclude,
String executionHint, QueryBuilder<?> filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds,
String executionHint, QueryBuilder filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds,
SignificanceHeuristic significanceHeuristic, AggregationContext context, AggregatorFactory<?> parent,
AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
super(name, type, config, context, parent, subFactoriesBuilder, metaData);

View File

@ -66,7 +66,7 @@ public class SignificantTermsParser extends AbstractTermsParser {
if (incExc != null) {
factory.includeExclude(incExc);
}
QueryBuilder<?> backgroundFilter = (QueryBuilder<?>) otherOptions.get(SignificantTermsAggregatorBuilder.BACKGROUND_FILTER);
QueryBuilder backgroundFilter = (QueryBuilder) otherOptions.get(SignificantTermsAggregatorBuilder.BACKGROUND_FILTER);
if (backgroundFilter != null) {
factory.backgroundFilter(backgroundFilter);
}
@ -89,7 +89,7 @@ public class SignificantTermsParser extends AbstractTermsParser {
return true;
} else if (parseFieldMatcher.match(currentFieldName, SignificantTermsAggregatorBuilder.BACKGROUND_FILTER)) {
QueryParseContext queryParseContext = new QueryParseContext(queriesRegistry, parser, parseFieldMatcher);
QueryBuilder<?> filter = queryParseContext.parseInnerQueryBuilder();
QueryBuilder filter = queryParseContext.parseInnerQueryBuilder();
otherOptions.put(SignificantTermsAggregatorBuilder.BACKGROUND_FILTER, filter);
return true;
}

View File

@ -120,9 +120,9 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
return new HighlightBuilder();
}
private QueryBuilder<?> queryBuilder;
private QueryBuilder queryBuilder;
private QueryBuilder<?> postQueryBuilder;
private QueryBuilder postQueryBuilder;
private int from = -1;
@ -371,7 +371,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
*
* @see org.elasticsearch.index.query.QueryBuilders
*/
public SearchSourceBuilder query(QueryBuilder<?> query) {
public SearchSourceBuilder query(QueryBuilder query) {
this.queryBuilder = query;
return this;
}
@ -379,7 +379,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
/**
* Gets the query for this request
*/
public QueryBuilder<?> query() {
public QueryBuilder query() {
return queryBuilder;
}
@ -388,7 +388,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
* only has affect on the search hits (not aggregations). This filter is
* always executed as last filtering mechanism.
*/
public SearchSourceBuilder postFilter(QueryBuilder<?> postFilter) {
public SearchSourceBuilder postFilter(QueryBuilder postFilter) {
this.postQueryBuilder = postFilter;
return this;
}
@ -396,7 +396,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
/**
* Gets the post filter for this request
*/
public QueryBuilder<?> postFilter() {
public QueryBuilder postFilter() {
return postQueryBuilder;
}
@ -910,11 +910,11 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
*/
public SearchSourceBuilder rewrite(QueryShardContext context) throws IOException {
assert (this.equals(shallowCopy(queryBuilder, postQueryBuilder)));
QueryBuilder<?> queryBuilder = null;
QueryBuilder queryBuilder = null;
if (this.queryBuilder != null) {
queryBuilder = this.queryBuilder.rewrite(context);
}
QueryBuilder<?> postQueryBuilder = null;
QueryBuilder postQueryBuilder = null;
if (this.postQueryBuilder != null) {
postQueryBuilder = this.postQueryBuilder.rewrite(context);
}
@ -925,7 +925,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
return this;
}
private SearchSourceBuilder shallowCopy(QueryBuilder<?> queryBuilder, QueryBuilder<?> postQueryBuilder) {
private SearchSourceBuilder shallowCopy(QueryBuilder queryBuilder, QueryBuilder postQueryBuilder) {
SearchSourceBuilder rewrittenBuilder = new SearchSourceBuilder();
rewrittenBuilder.aggregations = aggregations;
rewrittenBuilder.explain = explain;

View File

@ -80,7 +80,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
protected String fragmenter;
protected QueryBuilder<?> highlightQuery;
protected QueryBuilder highlightQuery;
protected Order order;
@ -275,7 +275,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
* Sets a query to be used for highlighting instead of the search query.
*/
@SuppressWarnings("unchecked")
public HB highlightQuery(QueryBuilder<?> highlightQuery) {
public HB highlightQuery(QueryBuilder highlightQuery) {
this.highlightQuery = highlightQuery;
return (HB) this;
}
@ -283,7 +283,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
/**
* @return the value set by {@link #highlightQuery(QueryBuilder)}
*/
public QueryBuilder<?> highlightQuery() {
public QueryBuilder highlightQuery() {
return this.highlightQuery;
}

View File

@ -41,7 +41,7 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
public static final float DEFAULT_RESCORE_QUERYWEIGHT = 1.0f;
public static final float DEFAULT_QUERYWEIGHT = 1.0f;
public static final QueryRescoreMode DEFAULT_SCORE_MODE = QueryRescoreMode.Total;
private final QueryBuilder<?> queryBuilder;
private final QueryBuilder queryBuilder;
private float rescoreQueryWeight = DEFAULT_RESCORE_QUERYWEIGHT;
private float queryWeight = DEFAULT_QUERYWEIGHT;
private QueryRescoreMode scoreMode = DEFAULT_SCORE_MODE;
@ -70,7 +70,7 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
* Creates a new {@link QueryRescorerBuilder} instance
* @param builder the query builder to build the rescore query from
*/
public QueryRescorerBuilder(QueryBuilder<?> builder) {
public QueryRescorerBuilder(QueryBuilder builder) {
this.queryBuilder = builder;
}
@ -96,7 +96,7 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
/**
* @return the query used for this rescore query
*/
public QueryBuilder<?> getRescoreQuery() {
public QueryBuilder getRescoreQuery() {
return this.queryBuilder;
}
@ -209,12 +209,12 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
*/
private static class InnerBuilder {
private QueryBuilder<?> queryBuilder;
private QueryBuilder queryBuilder;
private float rescoreQueryWeight = DEFAULT_RESCORE_QUERYWEIGHT;
private float queryWeight = DEFAULT_QUERYWEIGHT;
private QueryRescoreMode scoreMode = DEFAULT_SCORE_MODE;
void setQueryBuilder(QueryBuilder<?> builder) {
void setQueryBuilder(QueryBuilder builder) {
this.queryBuilder = builder;
}

View File

@ -125,7 +125,7 @@ public abstract class RescoreBuilder<RB extends RescoreBuilder<RB>> extends ToXC
public abstract QueryRescoreContext build(QueryShardContext context) throws IOException;
public static QueryRescorerBuilder queryRescorer(QueryBuilder<?> queryBuilder) {
public static QueryRescorerBuilder queryRescorer(QueryBuilder queryBuilder) {
return new QueryRescorerBuilder(queryBuilder);
}

View File

@ -66,7 +66,7 @@ public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> {
private SortMode sortMode;
private QueryBuilder<?> nestedFilter;
private QueryBuilder nestedFilter;
private String nestedPath;
@ -189,7 +189,7 @@ public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> {
* TODO should the above getters and setters be deprecated/ changed in
* favour of real getters and setters?
*/
public FieldSortBuilder setNestedFilter(QueryBuilder<?> nestedFilter) {
public FieldSortBuilder setNestedFilter(QueryBuilder nestedFilter) {
this.nestedFilter = nestedFilter;
return this;
}
@ -198,7 +198,7 @@ public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> {
* Returns the nested filter that the nested objects should match with in
* order to be taken into account for sorting.
*/
public QueryBuilder<?> getNestedFilter() {
public QueryBuilder getNestedFilter() {
return this.nestedFilter;
}
@ -324,7 +324,7 @@ public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> {
public static FieldSortBuilder fromXContent(QueryParseContext context, String fieldName) throws IOException {
XContentParser parser = context.parser();
QueryBuilder<?> nestedFilter = null;
QueryBuilder nestedFilter = null;
String nestedPath = null;
Object missing = null;
SortOrder order = null;

View File

@ -292,7 +292,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
* Sets the nested filter that the nested objects should match with in order to be taken into account
* for sorting.
*/
public GeoDistanceSortBuilder setNestedFilter(QueryBuilder<?> nestedFilter) {
public GeoDistanceSortBuilder setNestedFilter(QueryBuilder nestedFilter) {
this.nestedFilter = nestedFilter;
return this;
}
@ -301,7 +301,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
* Returns the nested filter that the nested objects should match with in order to be taken into account
* for sorting.
**/
public QueryBuilder<?> getNestedFilter() {
public QueryBuilder getNestedFilter() {
return this.nestedFilter;
}
@ -406,7 +406,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
GeoDistance geoDistance = GeoDistance.DEFAULT;
SortOrder order = SortOrder.ASC;
SortMode sortMode = null;
QueryBuilder<?> nestedFilter = null;
QueryBuilder nestedFilter = null;
String nestedPath = null;
boolean coerce = GeoValidationMethod.DEFAULT_LENIENT_PARSING;

View File

@ -80,7 +80,7 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> {
private SortMode sortMode;
private QueryBuilder<?> nestedFilter;
private QueryBuilder nestedFilter;
private String nestedPath;
@ -170,7 +170,7 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> {
* Sets the nested filter that the nested objects should match with in order to be taken into account
* for sorting.
*/
public ScriptSortBuilder setNestedFilter(QueryBuilder<?> nestedFilter) {
public ScriptSortBuilder setNestedFilter(QueryBuilder nestedFilter) {
this.nestedFilter = nestedFilter;
return this;
}
@ -178,7 +178,7 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> {
/**
* Gets the nested filter.
*/
public QueryBuilder<?> getNestedFilter() {
public QueryBuilder getNestedFilter() {
return this.nestedFilter;
}
@ -236,7 +236,7 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> {
ScriptSortType type = null;
SortMode sortMode = null;
SortOrder order = null;
QueryBuilder<?> nestedFilter = null;
QueryBuilder nestedFilter = null;
String nestedPath = null;
Map<String, Object> params = new HashMap<>();

View File

@ -169,7 +169,7 @@ public abstract class SortBuilder<T extends SortBuilder<T>> extends ToXContentTo
return Optional.empty();
}
protected static Nested resolveNested(QueryShardContext context, String nestedPath, QueryBuilder<?> nestedFilter) throws IOException {
protected static Nested resolveNested(QueryShardContext context, String nestedPath, QueryBuilder nestedFilter) throws IOException {
Nested nested = null;
if (nestedPath != null) {
BitSetProducer rootDocumentsFilter = context.bitsetFilter(Queries.newNonNestedFilter());

View File

@ -433,7 +433,7 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
return Collections.emptySet();
}
protected static XContentBuilder toXContent(QueryBuilder<?> query, XContentType contentType) throws IOException {
protected static XContentBuilder toXContent(QueryBuilder query, XContentType contentType) throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
if (randomBoolean()) {
builder.prettyPrint();
@ -499,12 +499,12 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
/**
* Parses the query provided as string argument and compares it with the expected result provided as argument as a {@link QueryBuilder}
*/
protected final void assertParsedQuery(String queryAsString, QueryBuilder<?> expectedQuery) throws IOException {
protected final void assertParsedQuery(String queryAsString, QueryBuilder expectedQuery) throws IOException {
assertParsedQuery(queryAsString, expectedQuery, ParseFieldMatcher.STRICT);
}
protected final void assertParsedQuery(String queryAsString, QueryBuilder<?> expectedQuery, ParseFieldMatcher matcher) throws IOException {
QueryBuilder<?> newQuery = parseQuery(queryAsString, matcher);
protected final void assertParsedQuery(String queryAsString, QueryBuilder expectedQuery, ParseFieldMatcher matcher) throws IOException {
QueryBuilder newQuery = parseQuery(queryAsString, matcher);
assertNotSame(newQuery, expectedQuery);
assertEquals(expectedQuery, newQuery);
assertEquals(expectedQuery.hashCode(), newQuery.hashCode());
@ -513,38 +513,38 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
/**
* Parses the query provided as bytes argument and compares it with the expected result provided as argument as a {@link QueryBuilder}
*/
protected final void assertParsedQuery(BytesReference queryAsBytes, QueryBuilder<?> expectedQuery) throws IOException {
protected final void assertParsedQuery(BytesReference queryAsBytes, QueryBuilder expectedQuery) throws IOException {
assertParsedQuery(queryAsBytes, expectedQuery, ParseFieldMatcher.STRICT);
}
protected final void assertParsedQuery(BytesReference queryAsBytes, QueryBuilder<?> expectedQuery, ParseFieldMatcher matcher) throws IOException {
QueryBuilder<?> newQuery = parseQuery(queryAsBytes, matcher);
protected final void assertParsedQuery(BytesReference queryAsBytes, QueryBuilder expectedQuery, ParseFieldMatcher matcher) throws IOException {
QueryBuilder newQuery = parseQuery(queryAsBytes, matcher);
assertNotSame(newQuery, expectedQuery);
assertEquals(expectedQuery, newQuery);
assertEquals(expectedQuery.hashCode(), newQuery.hashCode());
}
protected final QueryBuilder<?> parseQuery(String queryAsString) throws IOException {
protected final QueryBuilder parseQuery(String queryAsString) throws IOException {
return parseQuery(queryAsString, ParseFieldMatcher.STRICT);
}
protected final QueryBuilder<?> parseQuery(String queryAsString, ParseFieldMatcher matcher) throws IOException {
protected final QueryBuilder parseQuery(String queryAsString, ParseFieldMatcher matcher) throws IOException {
XContentParser parser = XContentFactory.xContent(queryAsString).createParser(queryAsString);
return parseQuery(parser, matcher);
}
protected final QueryBuilder<?> parseQuery(BytesReference queryAsBytes) throws IOException {
protected final QueryBuilder parseQuery(BytesReference queryAsBytes) throws IOException {
return parseQuery(queryAsBytes, ParseFieldMatcher.STRICT);
}
protected final QueryBuilder<?> parseQuery(BytesReference queryAsBytes, ParseFieldMatcher matcher) throws IOException {
protected final QueryBuilder parseQuery(BytesReference queryAsBytes, ParseFieldMatcher matcher) throws IOException {
XContentParser parser = XContentFactory.xContent(queryAsBytes).createParser(queryAsBytes);
return parseQuery(parser, matcher);
}
private QueryBuilder<?> parseQuery(XContentParser parser, ParseFieldMatcher matcher) throws IOException {
private QueryBuilder parseQuery(XContentParser parser, ParseFieldMatcher matcher) throws IOException {
QueryParseContext context = createParseContext(parser, matcher);
QueryBuilder<?> parseInnerQueryBuilder = context.parseInnerQueryBuilder();
QueryBuilder parseInnerQueryBuilder = context.parseInnerQueryBuilder();
assertNull(parser.nextToken());
return parseInnerQueryBuilder;
}
@ -602,8 +602,8 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
}
}
private QueryBuilder<?> rewriteQuery(QB queryBuilder, QueryRewriteContext rewriteContext) throws IOException {
QueryBuilder<?> rewritten = QueryBuilder.rewriteQuery(queryBuilder, rewriteContext);
private QueryBuilder rewriteQuery(QB queryBuilder, QueryRewriteContext rewriteContext) throws IOException {
QueryBuilder rewritten = QueryBuilder.rewriteQuery(queryBuilder, rewriteContext);
// extra safety to fail fast - serialize the rewritten version to ensure it's serializable.
assertSerialization(rewritten);
return rewritten;
@ -686,7 +686,7 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
try (BytesStreamOutput output = new BytesStreamOutput()) {
output.writeNamedWriteable(testQuery);
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
QueryBuilder<?> deserializedQuery = in.readNamedWriteable(QueryBuilder.class);
QueryBuilder deserializedQuery = in.readNamedWriteable(QueryBuilder.class);
assertEquals(testQuery, deserializedQuery);
assertEquals(testQuery.hashCode(), deserializedQuery.hashCode());
assertNotSame(testQuery, deserializedQuery);
@ -963,7 +963,7 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
* <li> By now the roundtrip check for the json should be happy.
* </ul>
**/
public static void checkGeneratedJson(String expected, QueryBuilder<?> source) throws IOException {
public static void checkGeneratedJson(String expected, QueryBuilder source) throws IOException {
// now assert that we actually generate the same JSON
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
source.toXContent(builder, ToXContent.EMPTY_PARAMS);

View File

@ -113,9 +113,9 @@ public class BoolQueryBuilderTests extends AbstractQueryTestCase<BoolQueryBuilde
}
}
private static List<BooleanClause> getBooleanClauses(List<QueryBuilder<?>> queryBuilders, BooleanClause.Occur occur, QueryShardContext context) throws IOException {
private static List<BooleanClause> getBooleanClauses(List<QueryBuilder> queryBuilders, BooleanClause.Occur occur, QueryShardContext context) throws IOException {
List<BooleanClause> clauses = new ArrayList<>();
for (QueryBuilder<?> query : queryBuilders) {
for (QueryBuilder query : queryBuilders) {
Query innerQuery = query.toQuery(context);
if (innerQuery != null) {
clauses.add(new BooleanClause(innerQuery, occur));
@ -132,22 +132,22 @@ public class BoolQueryBuilderTests extends AbstractQueryTestCase<BoolQueryBuilde
String contentString = "{\n" +
" \"bool\" : {\n";
if (tempQueryBuilder.must().size() > 0) {
QueryBuilder<?> must = tempQueryBuilder.must().get(0);
QueryBuilder must = tempQueryBuilder.must().get(0);
contentString += "\"must\": " + must.toString() + ",";
expectedQuery.must(must);
}
if (tempQueryBuilder.mustNot().size() > 0) {
QueryBuilder<?> mustNot = tempQueryBuilder.mustNot().get(0);
QueryBuilder mustNot = tempQueryBuilder.mustNot().get(0);
contentString += (randomBoolean() ? "\"must_not\": " : "\"mustNot\": ") + mustNot.toString() + ",";
expectedQuery.mustNot(mustNot);
}
if (tempQueryBuilder.should().size() > 0) {
QueryBuilder<?> should = tempQueryBuilder.should().get(0);
QueryBuilder should = tempQueryBuilder.should().get(0);
contentString += "\"should\": " + should.toString() + ",";
expectedQuery.should(should);
}
if (tempQueryBuilder.filter().size() > 0) {
QueryBuilder<?> filter = tempQueryBuilder.filter().get(0);
QueryBuilder filter = tempQueryBuilder.filter().get(0);
contentString += "\"filter\": " + filter.toString() + ",";
expectedQuery.filter(filter);
}
@ -366,7 +366,7 @@ public class BoolQueryBuilderTests extends AbstractQueryTestCase<BoolQueryBuilde
if (mustRewrite == false && randomBoolean()) {
boolQueryBuilder.must(new TermsQueryBuilder("foo", "no_rewrite"));
}
QueryBuilder<?> rewritten = boolQueryBuilder.rewrite(createShardContext());
QueryBuilder rewritten = boolQueryBuilder.rewrite(createShardContext());
if (mustRewrite == false && boolQueryBuilder.must().isEmpty()) {
// if it's empty we rewrite to match all
assertEquals(rewritten, new MatchAllQueryBuilder());
@ -398,14 +398,14 @@ public class BoolQueryBuilderTests extends AbstractQueryTestCase<BoolQueryBuilde
public void testRewriteMultipleTimes() throws IOException {
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
boolQueryBuilder.must(new WrapperQueryBuilder(new WrapperQueryBuilder(new MatchAllQueryBuilder().toString()).toString()));
QueryBuilder<?> rewritten = boolQueryBuilder.rewrite(createShardContext());
QueryBuilder rewritten = boolQueryBuilder.rewrite(createShardContext());
BoolQueryBuilder expected = new BoolQueryBuilder();
expected.must(new WrapperQueryBuilder(new MatchAllQueryBuilder().toString()));
assertEquals(expected, rewritten);
expected = new BoolQueryBuilder();
expected.must(new MatchAllQueryBuilder());
QueryBuilder<?> rewrittenAgain = rewritten.rewrite(createShardContext());
QueryBuilder rewrittenAgain = rewritten.rewrite(createShardContext());
assertEquals(rewrittenAgain, expected);
assertEquals(QueryBuilder.rewriteQuery(boolQueryBuilder, createShardContext()), expected);
}

View File

@ -108,7 +108,7 @@ public class BoostingQueryBuilderTests extends AbstractQueryTestCase<BoostingQue
QueryBuilder positive = randomBoolean() ? new MatchAllQueryBuilder() : new WrapperQueryBuilder(new TermQueryBuilder("pos", "bar").toString());
QueryBuilder negative = randomBoolean() ? new MatchAllQueryBuilder() : new WrapperQueryBuilder(new TermQueryBuilder("neg", "bar").toString());
BoostingQueryBuilder qb = new BoostingQueryBuilder(positive, negative);
QueryBuilder<?> rewrite = qb.rewrite(createShardContext());
QueryBuilder rewrite = qb.rewrite(createShardContext());
if (positive instanceof MatchAllQueryBuilder && negative instanceof MatchAllQueryBuilder) {
assertSame(rewrite, qb);
} else {

View File

@ -96,7 +96,7 @@ public class ConstantScoreQueryBuilderTests extends AbstractQueryTestCase<Consta
}
public void testIllegalArguments() {
expectThrows(IllegalArgumentException.class, () -> new ConstantScoreQueryBuilder((QueryBuilder<?>) null));
expectThrows(IllegalArgumentException.class, () -> new ConstantScoreQueryBuilder((QueryBuilder) null));
}
@Override

View File

@ -74,7 +74,7 @@ public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBu
@Override
protected Map<String, DisMaxQueryBuilder> getAlternateVersions() {
Map<String, DisMaxQueryBuilder> alternateVersions = new HashMap<>();
QueryBuilder<?> innerQuery = createTestQueryBuilder().innerQueries().get(0);
QueryBuilder innerQuery = createTestQueryBuilder().innerQueries().get(0);
DisMaxQueryBuilder expectedQuery = new DisMaxQueryBuilder();
expectedQuery.add(innerQuery);
String contentString = "{\n" +
@ -101,7 +101,7 @@ public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBu
*/
public void testInnerQueryReturnsNull() throws IOException {
String queryString = "{ \"" + ConstantScoreQueryBuilder.NAME + "\" : { \"filter\" : { } } }";
QueryBuilder<?> innerQueryBuilder = parseQuery(queryString);
QueryBuilder innerQueryBuilder = parseQuery(queryString);
DisMaxQueryBuilder disMaxBuilder = new DisMaxQueryBuilder().add(innerQueryBuilder);
assertNull(disMaxBuilder.toQuery(createShardContext()));
}

View File

@ -494,7 +494,7 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
" \"boost\" : 1.0\n" +
" }\n" +
"}";
QueryBuilder<?> parsedGeoBboxShortcut = parseQuery(json, ParseFieldMatcher.EMPTY);
QueryBuilder parsedGeoBboxShortcut = parseQuery(json, ParseFieldMatcher.EMPTY);
assertThat(parsedGeoBboxShortcut, equalTo(parsed));
try {

View File

@ -261,7 +261,7 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
} catch (UnsupportedOperationException e) {
assertEquals("query must be rewritten first", e.getMessage());
}
QueryBuilder<?> rewrite = sqb.rewrite(createShardContext());
QueryBuilder rewrite = sqb.rewrite(createShardContext());
GeoShapeQueryBuilder geoShapeQueryBuilder = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, indexedShapeToReturn);
geoShapeQueryBuilder.strategy(sqb.strategy());
geoShapeQueryBuilder.relation(sqb.relation());

View File

@ -115,7 +115,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase<HasChildQue
@Override
protected void doAssertLuceneQuery(HasChildQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException {
QueryBuilder<?> innerQueryBuilder = queryBuilder.query();
QueryBuilder innerQueryBuilder = queryBuilder.query();
if (innerQueryBuilder instanceof EmptyQueryBuilder) {
assertNull(query);
} else {
@ -149,7 +149,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase<HasChildQue
}
public void testIllegalValues() {
QueryBuilder<?> query = RandomQueryBuilder.createQuery(random());
QueryBuilder query = RandomQueryBuilder.createQuery(random());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> QueryBuilders.hasChildQuery(null, query, ScoreMode.None));
assertEquals("[has_child] requires 'type' field", e.getMessage());

View File

@ -71,7 +71,7 @@ public class IndicesQueryBuilderTests extends AbstractQueryTestCase<IndicesQuery
expectThrows(IllegalArgumentException.class, () -> new IndicesQueryBuilder(new MatchAllQueryBuilder(), new String[0]));
IndicesQueryBuilder indicesQueryBuilder = new IndicesQueryBuilder(new MatchAllQueryBuilder(), "index");
expectThrows(IllegalArgumentException.class, () -> indicesQueryBuilder.noMatchQuery((QueryBuilder<?>) null));
expectThrows(IllegalArgumentException.class, () -> indicesQueryBuilder.noMatchQuery((QueryBuilder) null));
expectThrows(IllegalArgumentException.class, () -> indicesQueryBuilder.noMatchQuery((String) null));
}

View File

@ -247,7 +247,7 @@ public class InnerHitBuilderTests extends ESTestCase {
}
if (includeQueryTypeOrPath) {
QueryBuilder<?> query = new MatchQueryBuilder(randomAsciiOfLengthBetween(1, 16), randomAsciiOfLengthBetween(1, 16));
QueryBuilder query = new MatchQueryBuilder(randomAsciiOfLengthBetween(1, 16), randomAsciiOfLengthBetween(1, 16));
if (randomBoolean()) {
return new InnerHitBuilder(innerHits, randomAsciiOfLength(8), query);
} else {

View File

@ -114,7 +114,7 @@ public class NestedQueryBuilderTests extends AbstractQueryTestCase<NestedQueryBu
}
public void testValidate() {
QueryBuilder<?> innerQuery = RandomQueryBuilder.createQuery(random());
QueryBuilder innerQuery = RandomQueryBuilder.createQuery(random());
IllegalArgumentException e =
expectThrows(IllegalArgumentException.class, () -> QueryBuilders.nestedQuery(null, innerQuery, ScoreMode.Avg));
assertThat(e.getMessage(), equalTo("[nested] requires 'path' field"));

View File

@ -142,7 +142,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
PercolateQueryBuilder pqb = doCreateTestQueryBuilder(true);
IllegalStateException e = expectThrows(IllegalStateException.class, () -> pqb.toQuery(createShardContext()));
assertThat(e.getMessage(), equalTo("query builder must be rewritten first"));
QueryBuilder<?> rewrite = pqb.rewrite(createShardContext());
QueryBuilder rewrite = pqb.rewrite(createShardContext());
PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder(pqb.getField(), pqb.getDocumentType(), documentSource);
assertEquals(geoShapeQueryBuilder, rewrite);
}

View File

@ -413,7 +413,7 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
" \"query\":\"" + DATE_FIELD_NAME + ":[2012 TO 2014]\"\n" +
" }\n" +
"}";
QueryBuilder<?> queryBuilder = parseQuery(queryAsString);
QueryBuilder queryBuilder = parseQuery(queryAsString);
assertThat(queryBuilder, instanceOf(QueryStringQueryBuilder.class));
QueryStringQueryBuilder queryStringQueryBuilder = (QueryStringQueryBuilder) queryBuilder;
assertThat(queryStringQueryBuilder.timeZone(), equalTo(DateTimeZone.forID("Europe/Paris")));

View File

@ -36,7 +36,7 @@ public class RandomQueryBuilder {
* @param r random seed
* @return a random {@link QueryBuilder}
*/
public static QueryBuilder<?> createQuery(Random r) {
public static QueryBuilder createQuery(Random r) {
switch (RandomInts.randomIntBetween(r, 0, 4)) {
case 0:
return new MatchAllQueryBuilderTests().createTestQueryBuilder();
@ -61,7 +61,7 @@ public class RandomQueryBuilder {
public static MultiTermQueryBuilder createMultiTermQuery(Random r) {
// for now, only use String Rangequeries for MultiTerm test, numeric and date makes little sense
// see issue #12123 for discussion
MultiTermQueryBuilder<?> multiTermQueryBuilder;
MultiTermQueryBuilder multiTermQueryBuilder;
switch(RandomInts.randomIntBetween(r, 0, 3)) {
case 0:
RangeQueryBuilder stringRangeQuery = new RangeQueryBuilder(AbstractQueryTestCase.STRING_FIELD_NAME);

View File

@ -464,7 +464,7 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
query.from(queryFromValue);
query.to(queryToValue);
QueryShardContext queryShardContext = createShardContext();
QueryBuilder<?> rewritten = query.rewrite(queryShardContext);
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, instanceOf(RangeQueryBuilder.class));
RangeQueryBuilder rewrittenRange = (RangeQueryBuilder) rewritten;
assertThat(rewrittenRange.fieldName(), equalTo(fieldName));
@ -485,7 +485,7 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
query.from(queryFromValue);
query.to(queryToValue);
QueryShardContext queryShardContext = createShardContext();
QueryBuilder<?> rewritten = query.rewrite(queryShardContext);
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, instanceOf(MatchNoneQueryBuilder.class));
}
@ -502,7 +502,7 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
query.from(queryFromValue);
query.to(queryToValue);
QueryShardContext queryShardContext = createShardContext();
QueryBuilder<?> rewritten = query.rewrite(queryShardContext);
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, sameInstance(query));
}
@ -515,7 +515,7 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
}
};
QueryShardContext queryShardContext = createShardContext();
QueryBuilder<?> rewritten = query.rewrite(queryShardContext);
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, sameInstance(query));
}
}

View File

@ -59,7 +59,7 @@ public class SpanMultiTermQueryBuilderTests extends AbstractQueryTestCase<SpanMu
}
public void testIllegalArgument() {
expectThrows(IllegalArgumentException.class, () -> new SpanMultiTermQueryBuilder((MultiTermQueryBuilder<?>) null));
expectThrows(IllegalArgumentException.class, () -> new SpanMultiTermQueryBuilder((MultiTermQueryBuilder) null));
}
/**

View File

@ -50,7 +50,7 @@ public class SpanNearQueryBuilderTests extends AbstractQueryTestCase<SpanNearQue
assertThat(spanNearQuery.getSlop(), equalTo(queryBuilder.slop()));
assertThat(spanNearQuery.isInOrder(), equalTo(queryBuilder.inOrder()));
assertThat(spanNearQuery.getClauses().length, equalTo(queryBuilder.clauses().size()));
Iterator<SpanQueryBuilder<?>> spanQueryBuilderIterator = queryBuilder.clauses().iterator();
Iterator<SpanQueryBuilder> spanQueryBuilderIterator = queryBuilder.clauses().iterator();
for (SpanQuery spanQuery : spanNearQuery.getClauses()) {
assertThat(spanQuery, equalTo(spanQueryBuilderIterator.next().toQuery(context)));
}

View File

@ -45,14 +45,14 @@ public class SpanOrQueryBuilderTests extends AbstractQueryTestCase<SpanOrQueryBu
assertThat(query, instanceOf(SpanOrQuery.class));
SpanOrQuery spanOrQuery = (SpanOrQuery) query;
assertThat(spanOrQuery.getClauses().length, equalTo(queryBuilder.clauses().size()));
Iterator<SpanQueryBuilder<?>> spanQueryBuilderIterator = queryBuilder.clauses().iterator();
Iterator<SpanQueryBuilder> spanQueryBuilderIterator = queryBuilder.clauses().iterator();
for (SpanQuery spanQuery : spanOrQuery.getClauses()) {
assertThat(spanQuery, equalTo(spanQueryBuilderIterator.next().toQuery(context)));
}
}
public void testIllegalArguments() {
expectThrows(IllegalArgumentException.class, () -> new SpanOrQueryBuilder((SpanQueryBuilder<?>) null));
expectThrows(IllegalArgumentException.class, () -> new SpanOrQueryBuilder((SpanQueryBuilder) null));
try {
SpanOrQueryBuilder spanOrBuilder = new SpanOrQueryBuilder(new SpanTermQueryBuilder("field", "value"));

View File

@ -40,7 +40,7 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
/**
* The query type all template tests will be based on.
*/
private static QueryBuilder<?> templateBase;
private static QueryBuilder templateBase;
@BeforeClass
public static void setupClass() {
@ -102,7 +102,7 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
String query = "{\"template\": {\"query\": \"{\\\"match_{{template}}\\\": {}}\\\"\",\"params\" : {\"template\" : \"all\"}}}";
Map<String, Object> params = new HashMap<>();
params.put("template", "all");
QueryBuilder<?> expectedBuilder = new TemplateQueryBuilder(new Template(expectedTemplateString, ScriptType.INLINE, null, null,
QueryBuilder expectedBuilder = new TemplateQueryBuilder(new Template(expectedTemplateString, ScriptType.INLINE, null, null,
params));
assertParsedQuery(query, expectedBuilder);
}
@ -112,7 +112,7 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
String query = "{\"template\": {\"query\": {\"match_{{template}}\": {}},\"params\" : {\"template\" : \"all\"}}}";
Map<String, Object> params = new HashMap<>();
params.put("template", "all");
QueryBuilder<?> expectedBuilder = new TemplateQueryBuilder(new Template(expectedTemplateString, ScriptType.INLINE, null,
QueryBuilder expectedBuilder = new TemplateQueryBuilder(new Template(expectedTemplateString, ScriptType.INLINE, null,
XContentType.JSON, params));
assertParsedQuery(query, expectedBuilder);
}
@ -120,7 +120,7 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
@Override
public void testMustRewrite() throws IOException {
String query = "{ \"match_all\" : {}}";
QueryBuilder<?> builder = new TemplateQueryBuilder(new Template(query, ScriptType.INLINE, "mockscript",
QueryBuilder builder = new TemplateQueryBuilder(new Template(query, ScriptType.INLINE, "mockscript",
XContentType.JSON, Collections.emptyMap()));
try {
builder.toQuery(createShardContext());
@ -133,7 +133,7 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
public void testRewriteWithInnerName() throws IOException {
final String query = "{ \"match_all\" : {\"_name\" : \"foobar\"}}";
QueryBuilder<?> builder = new TemplateQueryBuilder(new Template(query, ScriptType.INLINE, "mockscript",
QueryBuilder builder = new TemplateQueryBuilder(new Template(query, ScriptType.INLINE, "mockscript",
XContentType.JSON, Collections.emptyMap()));
assertEquals(new MatchAllQueryBuilder().queryName("foobar"), builder.rewrite(createShardContext()));
@ -145,7 +145,7 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
public void testRewriteWithInnerBoost() throws IOException {
final TermQueryBuilder query = new TermQueryBuilder("foo", "bar").boost(2);
QueryBuilder<?> builder = new TemplateQueryBuilder(new Template(query.toString(), ScriptType.INLINE, "mockscript",
QueryBuilder builder = new TemplateQueryBuilder(new Template(query.toString(), ScriptType.INLINE, "mockscript",
XContentType.JSON, Collections.emptyMap()));
assertEquals(query, builder.rewrite(createShardContext()));

View File

@ -291,7 +291,7 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuil
" \"boost\" : 1.0\n" +
" }\n" +
"}";
QueryBuilder<?> inShortcutParsed = parseQuery(json, ParseFieldMatcher.EMPTY);
QueryBuilder inShortcutParsed = parseQuery(json, ParseFieldMatcher.EMPTY);
assertThat(inShortcutParsed, equalTo(parsed));
try {

View File

@ -54,7 +54,7 @@ public class WrapperQueryBuilderTests extends AbstractQueryTestCase<WrapperQuery
@Override
protected void doAssertLuceneQuery(WrapperQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException {
QueryBuilder<?> innerQuery = queryBuilder.rewrite(createShardContext());
QueryBuilder innerQuery = queryBuilder.rewrite(createShardContext());
Query expected = rewrite(innerQuery.toQuery(context));
assertEquals(rewrite(query), expected);
}
@ -138,12 +138,12 @@ public class WrapperQueryBuilderTests extends AbstractQueryTestCase<WrapperQuery
} catch (UnsupportedOperationException e) {
assertEquals("this query must be rewritten first", e.getMessage());
}
QueryBuilder<?> rewrite = qb.rewrite(createShardContext());
QueryBuilder rewrite = qb.rewrite(createShardContext());
assertEquals(tqb, rewrite);
}
public void testRewriteWithInnerName() throws IOException {
QueryBuilder<?> builder = new WrapperQueryBuilder("{ \"match_all\" : {\"_name\" : \"foobar\"}}");
QueryBuilder builder = new WrapperQueryBuilder("{ \"match_all\" : {\"_name\" : \"foobar\"}}");
QueryShardContext shardContext = createShardContext();
assertEquals(new MatchAllQueryBuilder().queryName("foobar"), builder.rewrite(shardContext));
builder = new WrapperQueryBuilder("{ \"match_all\" : {\"_name\" : \"foobar\"}}").queryName("outer");
@ -153,7 +153,7 @@ public class WrapperQueryBuilderTests extends AbstractQueryTestCase<WrapperQuery
public void testRewriteWithInnerBoost() throws IOException {
final TermQueryBuilder query = new TermQueryBuilder("foo", "bar").boost(2);
QueryBuilder<?> builder = new WrapperQueryBuilder(query.toString());
QueryBuilder builder = new WrapperQueryBuilder(query.toString());
QueryShardContext shardContext = createShardContext();
assertEquals(query, builder.rewrite(shardContext));
builder = new WrapperQueryBuilder(query.toString()).boost(3);

View File

@ -240,7 +240,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
public void testIllegalArguments() {
expectThrows(IllegalArgumentException.class, () -> new FunctionScoreQueryBuilder((QueryBuilder<?>) null));
expectThrows(IllegalArgumentException.class, () -> new FunctionScoreQueryBuilder((QueryBuilder) null));
expectThrows(IllegalArgumentException.class, () -> new FunctionScoreQueryBuilder((ScoreFunctionBuilder<?>) null));
expectThrows(IllegalArgumentException.class, () -> new FunctionScoreQueryBuilder((FilterFunctionBuilder[]) null));
expectThrows(IllegalArgumentException.class, () -> new FunctionScoreQueryBuilder(null, randomFunction(123)));
@ -301,7 +301,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
" }\n" +
"}";
QueryBuilder<?> queryBuilder = parseQuery(functionScoreQuery);
QueryBuilder queryBuilder = parseQuery(functionScoreQuery);
/*
* given that we copy part of the decay functions as bytes, we test that fromXContent and toXContent both work no matter what the
* initial format was
@ -343,7 +343,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
assertThat(functionScoreQueryBuilder.maxBoost(), equalTo(10f));
if (i < XContentType.values().length) {
queryBuilder = parseQuery(((AbstractQueryBuilder<?>) queryBuilder).buildAsBytes(XContentType.values()[i]));
queryBuilder = parseQuery(((AbstractQueryBuilder) queryBuilder).buildAsBytes(XContentType.values()[i]));
}
}
}
@ -369,7 +369,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
" }\n" +
"}";
QueryBuilder<?> queryBuilder = parseQuery(functionScoreQuery);
QueryBuilder queryBuilder = parseQuery(functionScoreQuery);
/*
* given that we copy part of the decay functions as bytes, we test that fromXContent and toXContent both work no matter what the
* initial format was
@ -395,7 +395,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
assertThat(functionScoreQueryBuilder.maxBoost(), equalTo(10f));
if (i < XContentType.values().length) {
queryBuilder = parseQuery(((AbstractQueryBuilder<?>) queryBuilder).buildAsBytes(XContentType.values()[i]));
queryBuilder = parseQuery(((AbstractQueryBuilder) queryBuilder).buildAsBytes(XContentType.values()[i]));
}
}
}
@ -476,7 +476,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
.endArray()
.endObject()
.endObject().string();
QueryBuilder<?> query = parseQuery(queryString);
QueryBuilder query = parseQuery(queryString);
assertThat(query, instanceOf(FunctionScoreQueryBuilder.class));
FunctionScoreQueryBuilder functionScoreQueryBuilder = (FunctionScoreQueryBuilder) query;
assertThat(functionScoreQueryBuilder.filterFunctionBuilders()[0].getScoreFunction(),
@ -618,9 +618,9 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
public void testRewriteWithFunction() throws IOException {
QueryBuilder<?> firstFunction = new WrapperQueryBuilder(new TermQueryBuilder("tq", "1").toString());
QueryBuilder firstFunction = new WrapperQueryBuilder(new TermQueryBuilder("tq", "1").toString());
TermQueryBuilder secondFunction = new TermQueryBuilder("tq", "2");
QueryBuilder<?> queryBuilder = randomBoolean() ? new WrapperQueryBuilder(new TermQueryBuilder("foo", "bar").toString())
QueryBuilder queryBuilder = randomBoolean() ? new WrapperQueryBuilder(new TermQueryBuilder("foo", "bar").toString())
: new TermQueryBuilder("foo", "bar");
FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(queryBuilder,
new FunctionScoreQueryBuilder.FilterFunctionBuilder[] {

View File

@ -109,7 +109,7 @@ public class FilterIT extends ESIntegTestCase {
// See NullPointer issue when filters are empty:
// https://github.com/elastic/elasticsearch/issues/8438
public void testEmptyFilterDeclarations() throws Exception {
QueryBuilder<?> emptyFilter = new BoolQueryBuilder();
QueryBuilder emptyFilter = new BoolQueryBuilder();
SearchResponse response = client().prepareSearch("idx").addAggregation(filter("tag1", emptyFilter)).execute().actionGet();
assertSearchResponse(response);
@ -120,7 +120,7 @@ public class FilterIT extends ESIntegTestCase {
}
public void testEmptyFilter() throws Exception {
QueryBuilder<?> emptyFilter = new EmptyQueryBuilder();
QueryBuilder emptyFilter = new EmptyQueryBuilder();
SearchResponse response = client().prepareSearch("idx").addAggregation(filter("tag1", emptyFilter)).execute().actionGet();
assertSearchResponse(response);

View File

@ -138,7 +138,7 @@ public class FiltersIT extends ESIntegTestCase {
// See NullPointer issue when filters are empty:
// https://github.com/elastic/elasticsearch/issues/8438
public void testEmptyFilterDeclarations() throws Exception {
QueryBuilder<?> emptyFilter = new BoolQueryBuilder();
QueryBuilder emptyFilter = new BoolQueryBuilder();
SearchResponse response = client().prepareSearch("idx")
.addAggregation(filters("tags", randomOrder(new KeyedFilter("all", emptyFilter),
new KeyedFilter("tag1", termQuery("tag", "tag1")))))
@ -207,7 +207,7 @@ public class FiltersIT extends ESIntegTestCase {
}
public void testEmptyFilter() throws Exception {
QueryBuilder<?> emptyFilter = new EmptyQueryBuilder();
QueryBuilder emptyFilter = new EmptyQueryBuilder();
SearchResponse response = client().prepareSearch("idx").addAggregation(filters("tag1", emptyFilter)).execute().actionGet();
assertSearchResponse(response);
@ -219,7 +219,7 @@ public class FiltersIT extends ESIntegTestCase {
}
public void testEmptyKeyedFilter() throws Exception {
QueryBuilder<?> emptyFilter = new EmptyQueryBuilder();
QueryBuilder emptyFilter = new EmptyQueryBuilder();
SearchResponse response = client().prepareSearch("idx").addAggregation(filters("tag1", new KeyedFilter("foo", emptyFilter)))
.execute().actionGet();

View File

@ -42,7 +42,7 @@ public class FiltersTests extends BaseAggregationTestCase<FiltersAggregatorBuild
}
factory = new FiltersAggregatorBuilder(randomAsciiOfLengthBetween(1, 20), filters);
} else {
QueryBuilder<?>[] filters = new QueryBuilder<?>[size];
QueryBuilder[] filters = new QueryBuilder[size];
for (int i = 0; i < size; i++) {
filters[i] = QueryBuilders.termQuery(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20));
}

View File

@ -78,7 +78,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
return pluginList(InternalSettingsPlugin.class); // uses index.version.created
}
private final QueryBuilder<?> baseQuery = constantScoreQuery(termQuery("test", "value"));
private final QueryBuilder baseQuery = constantScoreQuery(termQuery("test", "value"));
public void testDistanceScoreGeoLinGaussExp() throws Exception {
assertAcked(prepareCreate("test").addMapping(

View File

@ -583,7 +583,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
String[] intToEnglish = new String[] { English.intToEnglish(i), English.intToEnglish(i + 1), English.intToEnglish(i + 2),
English.intToEnglish(i + 3) };
QueryBuilder<?> query = boolQuery().disableCoord(true)
QueryBuilder query = boolQuery().disableCoord(true)
.should(functionScoreQuery(termQuery("field1", intToEnglish[0]), weightFactorFunction(2.0f)).boostMode(REPLACE))
.should(functionScoreQuery(termQuery("field1", intToEnglish[1]), weightFactorFunction(3.0f)).boostMode(REPLACE))
.should(functionScoreQuery(termQuery("field1", intToEnglish[2]), weightFactorFunction(5.0f)).boostMode(REPLACE))

View File

@ -314,7 +314,7 @@ public class QueryRescoreBuilderTests extends ESTestCase {
* create random shape that is put under test
*/
public static QueryRescorerBuilder randomRescoreBuilder() {
QueryBuilder<MatchAllQueryBuilder> queryBuilder = new MatchAllQueryBuilder().boost(randomFloat())
QueryBuilder queryBuilder = new MatchAllQueryBuilder().boost(randomFloat())
.queryName(randomAsciiOfLength(20));
org.elasticsearch.search.rescore.QueryRescorerBuilder rescorer = new
org.elasticsearch.search.rescore.QueryRescorerBuilder(queryBuilder);

View File

@ -256,7 +256,7 @@ public abstract class AbstractSortTestCase<T extends SortBuilder<T>> extends EST
return doubleFieldType;
}
protected static QueryBuilder<?> randomNestedFilter() {
protected static QueryBuilder randomNestedFilter() {
int id = randomIntBetween(0, 2);
switch(id) {
case 0: return (new MatchAllQueryBuilder()).boost(randomFloat());

View File

@ -279,20 +279,20 @@ requests can now be validated at call time which results in much clearer errors.
==== ValidateQueryRequest
`source(QuerySourceBuilder)`, `source(Map)`, `source(XContentBuilder)`, `source(String)`, `source(byte[])`, `source(byte[], int, int)`,
`source(BytesReference)` and `source()` have been removed in favor of using `query(QueryBuilder<?>)` and `query()`
`source(BytesReference)` and `source()` have been removed in favor of using `query(QueryBuilder)` and `query()`
==== ValidateQueryRequestBuilder
`setSource()` methods have been removed in favor of using `setQuery(QueryBuilder<?>)`
`setSource()` methods have been removed in favor of using `setQuery(QueryBuilder)`
==== ExplainRequest
`source(QuerySourceBuilder)`, `source(Map)`, `source(BytesReference)` and `source()` have been removed in favor of using
`query(QueryBuilder<?>)` and `query()`
`query(QueryBuilder)` and `query()`
==== ExplainRequestBuilder
The `setQuery(BytesReference)` method have been removed in favor of using `setQuery(QueryBuilder<?>)`
The `setQuery(BytesReference)` method have been removed in favor of using `setQuery(QueryBuilder)`
=== ClusterStatsResponse

View File

@ -68,7 +68,7 @@ public class MinDocCountTests extends AbstractTermsTestCase {
return Collections.singleton(GroovyPlugin.class);
}
private static final QueryBuilder<?> QUERY = QueryBuilders.termQuery("match", true);
private static final QueryBuilder QUERY = QueryBuilders.termQuery("match", true);
private static int cardinality;

View File

@ -62,7 +62,7 @@ public abstract class AbstractBulkByScrollRequestBuilder<
* Set the query that will filter the source. Just a convenience method for
* easy chaining.
*/
public Self filter(QueryBuilder<?> filter) {
public Self filter(QueryBuilder filter) {
source.setQuery(filter);
return self();
}

View File

@ -32,9 +32,9 @@ import static org.hamcrest.Matchers.equalTo;
* Index-by-search tests for parent/child.
*/
public class ReindexParentChildTests extends ReindexTestCase {
QueryBuilder<?> findsCountry;
QueryBuilder<?> findsCity;
QueryBuilder<?> findsNeighborhood;
QueryBuilder findsCountry;
QueryBuilder findsCity;
QueryBuilder findsNeighborhood;
public void testParentChild() throws Exception {
createParentChildIndex("source");

Some files were not shown because too many files have changed in this diff Show More