Interface SearchPredicateFactory
-
- All Known Subinterfaces:
ElasticsearchSearchPredicateFactory
,LuceneSearchPredicateFactory
- All Known Implementing Classes:
DelegatingSearchPredicateFactory
public interface SearchPredicateFactory
A factory for search predicates.This is the main entry point to the predicate DSL.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BooleanPredicateClausesStep<?>
bool()
Match documents if they match a combination of boolean clauses.PredicateFinalStep
bool(Consumer<? super BooleanPredicateClausesStep<?>> clauseContributor)
Match documents if they match a combination of boolean clauses, which will be defined by the given consumer.ExistsPredicateFieldStep<?>
exists()
Match documents where a given field exists.SearchPredicateFactoryExtensionIfSupportedStep
extension()
Create a DSL step allowing multiple attempts to apply extensions one after the other, failing only if none of the extensions is supported.<T> T
extension(SearchPredicateFactoryExtension<T> extension)
Extend the current factory with the given extension, resulting in an extended factory offering different types of predicates.MatchIdPredicateMatchingStep<?>
id()
Match documents where the identifier is among the given values.MatchPredicateFieldStep<?>
match()
Match documents where targeted fields have a value that "matches" a given single value.MatchAllPredicateOptionsStep<?>
matchAll()
Match all documents.NestedPredicateFieldStep<?>
nested()
Match documents where anested object
matches a given predicate.PhrasePredicateFieldStep<?>
phrase()
Match documents where targeted fields have a value that contains a given phrase.RangePredicateFieldStep<?>
range()
Match documents where targeted fields have a value within lower and upper bounds.SimpleQueryStringPredicateFieldStep<?>
simpleQueryString()
Match documents according to a given query string, with a simple query language adapted to end users.SpatialPredicateInitialStep
spatial()
Access the different types of spatial predicates.WildcardPredicateFieldStep<?>
wildcard()
Match documents where targeted fields contain a term that matches a given pattern, such asinter*on
orpa?t
.
-
-
-
Method Detail
-
matchAll
MatchAllPredicateOptionsStep<?> matchAll()
Match all documents.- Returns:
- The initial step of a DSL where the "match all" predicate can be defined.
- See Also:
MatchAllPredicateOptionsStep
-
id
MatchIdPredicateMatchingStep<?> id()
Match documents where the identifier is among the given values.- Returns:
- The initial step of a DSL allowing the definition of an "id" predicate.
- See Also:
MatchIdPredicateMatchingStep
-
bool
BooleanPredicateClausesStep<?> bool()
Match documents if they match a combination of boolean clauses.- Returns:
- The initial step of a DSL where the "boolean" predicate can be defined.
- See Also:
BooleanPredicateClausesStep
-
bool
PredicateFinalStep bool(Consumer<? super BooleanPredicateClausesStep<?>> clauseContributor)
Match documents if they match a combination of boolean clauses, which will be defined by the given consumer.Best used with lambda expressions.
- Parameters:
clauseContributor
- A consumer that will add clauses to the step passed in parameter. Should generally be a lambda expression.- Returns:
- The final step of the boolean predicate definition.
- See Also:
BooleanPredicateClausesStep
-
match
MatchPredicateFieldStep<?> match()
Match documents where targeted fields have a value that "matches" a given single value.Note that "value matching" may be exact or approximate depending on the type of the targeted fields: numeric fields in particular imply exact matches, while analyzed, full-text fields imply approximate matches depending on how they are analyzed.
- Returns:
- The initial step of a DSL where the "match" predicate can be defined.
- See Also:
MatchPredicateFieldStep
-
range
RangePredicateFieldStep<?> range()
Match documents where targeted fields have a value within lower and upper bounds.- Returns:
- The initial step of a DSL where the "range" predicate can be defined.
- See Also:
RangePredicateFieldStep
-
phrase
PhrasePredicateFieldStep<?> phrase()
Match documents where targeted fields have a value that contains a given phrase.- Returns:
- The initial step of a DSL where the "phrase" predicate can be defined.
- See Also:
PhrasePredicateFieldStep
-
wildcard
WildcardPredicateFieldStep<?> wildcard()
Match documents where targeted fields contain a term that matches a given pattern, such asinter*on
orpa?t
.Note that such patterns are not analyzed, thus any character that is not a wildcard must match exactly the content of the index (including uppercase letters, diacritics, ...).
- Returns:
- The initial step of a DSL where the "wildcard" predicate can be defined.
- See Also:
WildcardPredicateFieldStep
-
nested
NestedPredicateFieldStep<?> nested()
Match documents where anested object
matches a given predicate.- Returns:
- The initial step of a DSL where the "nested" predicate can be defined.
- See Also:
NestedPredicateFieldStep
-
simpleQueryString
SimpleQueryStringPredicateFieldStep<?> simpleQueryString()
Match documents according to a given query string, with a simple query language adapted to end users.Note that by default, unless the query string contains explicit operators, documents will match if any term mentioned in the query string is present in the document (OR operator). This makes sense when sorting results by relevance, but is not ideal otherwise. See
SimpleQueryStringPredicateOptionsStep.defaultOperator(BooleanOperator)
to change this behavior.- Returns:
- The initial step of a DSL where the "simple query string" predicate can be defined.
- See Also:
SimpleQueryStringPredicateFieldStep
-
exists
ExistsPredicateFieldStep<?> exists()
Match documents where a given field exists.Fields are considered to exist in a document when they have at least one non-null value in this document.
- Returns:
- The initial step of a DSL where the "exists" predicate can be defined.
- See Also:
ExistsPredicateFieldStep
-
spatial
SpatialPredicateInitialStep spatial()
Access the different types of spatial predicates.- Returns:
- The initial step of a DSL where spatial predicates can be defined.
- See Also:
SpatialPredicateInitialStep
-
extension
<T> T extension(SearchPredicateFactoryExtension<T> extension)
Extend the current factory with the given extension, resulting in an extended factory offering different types of predicates.- Type Parameters:
T
- The type of factory provided by the extension.- Parameters:
extension
- The extension to the predicate DSL.- Returns:
- The extended factory.
- Throws:
SearchException
- If the extension cannot be applied (wrong underlying backend, ...).
-
extension
SearchPredicateFactoryExtensionIfSupportedStep extension()
Create a DSL step allowing multiple attempts to apply extensions one after the other, failing only if none of the extensions is supported.If you only need to apply a single extension and fail if it is not supported, use the simpler
extension(SearchPredicateFactoryExtension)
method instead.- Returns:
- A DSL step.
-
-