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 Detail

      • 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)
        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)
        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

        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.

        See MinimumShouldMatchConditionStep.

        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.