Interface BooleanPredicateClausesStep<S extends BooleanPredicateClausesStep<?>>
-
- Type Parameters:
S
- The "self" type (the actual exposed type of this step).
- All Superinterfaces:
PredicateFinalStep
,PredicateScoreStep<S>
public interface BooleanPredicateClausesStep<S extends BooleanPredicateClausesStep<?>> extends PredicateScoreStep<S>, PredicateFinalStep
The initial and final step in a boolean predicate definition, where clauses can be added.Different types of clauses have different effects, see below.
"must" clauses
"must" clauses are required to match: if they don't match, then the boolean predicate will not match.
Matching "must" clauses are taken into account during score computation.
"must not" clauses
"must not" clauses are required to not match: if they match, then the boolean predicate will not match.
"must not" clauses are ignored during score computation.
"filter" clauses
"filter" clauses are required to match: if they don't match, then the boolean predicate will not match.
"filter" clauses are ignored during score computation, and so are any clauses of boolean predicates contained in the filter clause (even "must" or "should" clauses).
"should" clauses
"should" clauses may optionally match, and are required to match depending on the context.
Matching "should" clauses are taken into account during score computation.
The exact behavior of `should` clauses is as follows:
- When there isn't any "must" clause nor any "filter" clause in the boolean predicate, then at least one "should" clause is required to match. Simply put, in this case, the "should" clauses behave as if there was an "OR" operator between each of them.
- When there is at least one "must" clause or one "filter" clause in the boolean predicate, then the "should" clauses are not required to match, and are simply used for scoring.
- This behavior can be changed by specifying "minimumShouldMatch" constraints.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description S
filter(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "filter" clause to be defined by the given function.default S
filter(PredicateFinalStep dslFinalStep)
Add a "filter" clause based on an almost-builtSearchPredicate
.S
filter(SearchPredicate searchPredicate)
Add a "filter" clause based on a previously-builtSearchPredicate
.MinimumShouldMatchConditionStep<S>
minimumShouldMatch()
Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.S
minimumShouldMatch(Consumer<? super MinimumShouldMatchConditionStep<?>> constraintContributor)
Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.default S
minimumShouldMatchNumber(int matchingClausesNumber)
Add a default "minimumShouldMatch" constraint.default S
minimumShouldMatchPercent(int matchingClausesPercent)
Add a default "minimumShouldMatch" constraint.S
must(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "must" clause to be defined by the given function.default S
must(PredicateFinalStep dslFinalStep)
Add a "must" clause based on an almost-builtSearchPredicate
.S
must(SearchPredicate searchPredicate)
Add a "must" clause based on a previously-builtSearchPredicate
.S
mustNot(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "must not" clause to be defined by the given function.default S
mustNot(PredicateFinalStep dslFinalStep)
Add a "must not" clause based on an almost-builtSearchPredicate
.S
mustNot(SearchPredicate searchPredicate)
Add a "must not" clause based on a previously-builtSearchPredicate
.S
should(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "should" clause to be defined by the given function.default S
should(PredicateFinalStep dslFinalStep)
Add a "should" clause based on an almost-builtSearchPredicate
.S
should(SearchPredicate searchPredicate)
Add a "should" clause based on a previously-builtSearchPredicate
.-
Methods inherited from interface org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep
toPredicate
-
Methods inherited from interface org.hibernate.search.engine.search.predicate.dsl.PredicateScoreStep
boost, constantScore
-
-
-
-
Method Detail
-
must
S must(SearchPredicate searchPredicate)
Add a "must" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that must match.- Returns:
this
, for method chaining.
-
mustNot
S mustNot(SearchPredicate searchPredicate)
Add a "must not" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that must not match.- Returns:
this
, for method chaining.
-
should
S should(SearchPredicate searchPredicate)
Add a "should" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that should match.- Returns:
this
, for method chaining.
-
filter
S filter(SearchPredicate searchPredicate)
Add a "filter" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that must match.- Returns:
this
, for method chaining.
-
must
default S must(PredicateFinalStep dslFinalStep)
Add a "must" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
mustNot
default S mustNot(PredicateFinalStep dslFinalStep)
Add a "must not" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
should
default S should(PredicateFinalStep dslFinalStep)
Add a "should" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
filter
default S filter(PredicateFinalStep dslFinalStep)
Add a "filter" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
must
S must(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "must" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
mustNot
S mustNot(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "must not" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
should
S should(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "should" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
filter
S filter(Function<? super SearchPredicateFactory,? extends PredicateFinalStep> clauseContributor)
Add a "filter" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
minimumShouldMatchNumber
default S minimumShouldMatchNumber(int matchingClausesNumber)
Add a default "minimumShouldMatch" constraint.- Parameters:
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.- Returns:
this
, for method chaining.
-
minimumShouldMatchPercent
default S minimumShouldMatchPercent(int matchingClausesPercent)
Add a default "minimumShouldMatch" constraint.- Parameters:
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.- Returns:
this
, for method chaining.
-
minimumShouldMatch
MinimumShouldMatchConditionStep<S> minimumShouldMatch()
Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.- Returns:
- A
MinimumShouldMatchConditionStep
where constraints can be defined.
-
minimumShouldMatch
S minimumShouldMatch(Consumer<? super MinimumShouldMatchConditionStep<?>> constraintContributor)
Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.- Parameters:
constraintContributor
- A consumer that will add constraints to the DSL step passed in parameter. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
-