public interface BooleanJunction<T extends BooleanJunction> extends QueryCustomization<T>, Termination
"minimumShouldMatch" constraints define a minimum number of "should" clauses that have to match in order for the boolean junction to match.
The feature is similar, and will work identically, to
"Min Number Should Match"
in Solr or
minimum_should_match
in Elasticsearch.
The minimum may be defined either directly as a positive number, or indirectly as a negative number or positive or negative percentage representing a ratio of the total number of "should" clauses in this boolean junction.
Here is how each type of input is interpreted:
In any case, if the computed minimum is 0 or less, or higher than the total number of "should" clauses, behavior is backend-specific (it may throw an exception, or produce unpredictable results, or fall back to some default behavior).
Examples:
// Example 1: at least 3 "should" clauses have to match
booleanContext1.minimumShouldMatchNumber( 3 );
// Example 2: at most 2 "should" clauses may not match
booleanContext2.minimumShouldMatchNumber( -2 );
// Example 3: at least 75% of "should" clauses have to match (rounded down)
booleanContext3.minimumShouldMatchPercent( 75 );
// Example 4: at most 25% of "should" clauses may not match (rounded down)
booleanContext4.minimumShouldMatchPercent( -25 );
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty() |
BooleanJunction |
minimumShouldMatchNumber(int matchingClausesNumber)
Sets the "minimumShouldMatch" constraint.
|
BooleanJunction |
minimumShouldMatchPercent(int matchingClausesPercent)
Sets the "minimumShouldMatch" constraint.
|
MustJunction |
must(Query query)
The boolean query results must (or must not) match the subquery
Call the .not() method to ensure results of the boolean query do NOT match the subquery.
|
BooleanJunction |
should(Query query)
The boolean query results should match the subquery
|
boostedTo, filteredBy, filteredBy, withConstantScore
createQuery
BooleanJunction should(Query query)
query
- the query to match (nulls are ignored)BooleanJunction
MustJunction must(Query query)
query
- the query to match (nulls are ignored)MustJunction
boolean isEmpty()
BooleanJunction minimumShouldMatchNumber(int matchingClausesNumber)
matchingClausesNumber
- A definition of the number of "should" clauses that have to match.
If positive, it is the number of clauses that have to match.
See Definition of the minimum
for details and possible values, in particular negative values.this
, for method chaining.BooleanJunction minimumShouldMatchPercent(int matchingClausesPercent)
matchingClausesPercent
- A definition of the number of "should" clauses that have to match, as a percentage.
If positive, it is the percentage of the total number of "should" clauses that have to match.
See Definition of the minimum
for details and possible values, in particular negative values.this
, for method chaining.Copyright © 2006-2018 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.