public class BoolQueryBuilder extends QueryBuilder implements BoostableQueryBuilder<BoolQueryBuilder>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
EMPTY_PARAMS
Constructor and Description |
---|
BoolQueryBuilder() |
Modifier and Type | Method and Description |
---|---|
BoolQueryBuilder |
adjustPureNegative(boolean adjustPureNegative)
If a boolean query contains only negative ("must not") clauses should the
BooleanQuery be enhanced with a
MatchAllDocsQuery in order to act
as a pure exclude. |
BoolQueryBuilder |
boost(float boost)
Sets the boost for this query.
|
BoolQueryBuilder |
disableCoord(boolean disableCoord)
Disables Similarity#coord(int,int) in scoring.
|
protected void |
doXContent(XContentBuilder builder,
ToXContent.Params params) |
BoolQueryBuilder |
filter(QueryBuilder queryBuilder)
Adds a query that must appear in the matching documents but will
not contribute to scoring.
|
boolean |
hasClauses()
Returns
true iff this query builder has at least one should, must, must not or filter clause. |
BoolQueryBuilder |
minimumNumberShouldMatch(int minimumNumberShouldMatch)
Specifies a minimum number of the optional (should) boolean clauses which must be satisfied.
|
BoolQueryBuilder |
minimumShouldMatch(String minimumShouldMatch)
Sets the minimum should match using the special syntax (for example, supporting percentage).
|
BoolQueryBuilder |
must(QueryBuilder queryBuilder)
Adds a query that must appear in the matching documents and will
contribute to scoring.
|
BoolQueryBuilder |
mustNot(QueryBuilder queryBuilder)
Adds a query that must not appear in the matching documents and
will not contribute to scoring.
|
BoolQueryBuilder |
queryName(String queryName)
Sets the query name for the filter that can be used when searching for matched_filters per hit.
|
BoolQueryBuilder |
should(QueryBuilder queryBuilder)
Adds a query that should appear in the matching documents.
|
toXContent
buildAsBytes, buildAsBytes, toString
public BoolQueryBuilder must(QueryBuilder queryBuilder)
public BoolQueryBuilder filter(QueryBuilder queryBuilder)
public BoolQueryBuilder mustNot(QueryBuilder queryBuilder)
public BoolQueryBuilder should(QueryBuilder queryBuilder)
SHOULD
clauses must match a document
for the BooleanQuery to match.minimumNumberShouldMatch(int)
public BoolQueryBuilder boost(float boost)
boost
in interface BoostableQueryBuilder<BoolQueryBuilder>
public BoolQueryBuilder disableCoord(boolean disableCoord)
public BoolQueryBuilder minimumNumberShouldMatch(int minimumNumberShouldMatch)
By default no optional clauses are necessary for a match (unless there are no required clauses). If this method is used, then the specified number of clauses is required.
Use of this method is totally independent of specifying that any specific clauses are required (or prohibited). This number will only be compared against the number of matching optional clauses.
minimumNumberShouldMatch
- the number of optional clauses that must matchpublic BoolQueryBuilder minimumShouldMatch(String minimumShouldMatch)
public boolean hasClauses()
true
iff this query builder has at least one should, must, must not or filter clause.
Otherwise false
.public BoolQueryBuilder adjustPureNegative(boolean adjustPureNegative)
MatchAllDocsQuery
in order to act
as a pure exclude. The default is true
.public BoolQueryBuilder queryName(String queryName)
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
doXContent
in class QueryBuilder
IOException
Copyright © 2009–2016. All rights reserved.