Interface TypedSearchPredicateFactory<SR>
- Type Parameters:
SR
- Scope root type.
- All Superinterfaces:
SearchPredicateFactory
- All Known Subinterfaces:
ElasticsearchSearchPredicateFactory<SR>
,ExtendedSearchPredicateFactory<SR,
,S> LuceneSearchPredicateFactory<SR>
- All Known Implementing Classes:
AbstractSearchPredicateFactory
This is the main entry point to the predicate DSL.
Field paths
By default, field paths passed to this DSL are interpreted as absolute, i.e. relative to the index root.
However, a new, "relative" factory can be created with withRoot(String)
:
the new factory interprets paths as relative to the object field passed as argument to the method.
This can be useful when calling reusable methods that can apply the same predicate on different object fields that have same structure (same sub-fields).
Such a factory can also transform relative paths into absolute paths using toAbsolutePath(String)
;
this can be useful for native predicates in particular.
Field references
Afield reference
is always represented by the absolute field path and,
if applicable, i.e. when a field reference is typed, a combination of the ValueModel
and the type.
Field references are usually accessed from the generated Hibernate Search's static metamodel classes that describe the index structure.
Such reference provides the information on which search capabilities the particular index field possesses, and allows switching between different
value model representations
.
-
Method Summary
Modifier and TypeMethodDescriptionand()
Match documents if they match all inner clauses.bool()
Match documents if they match a combination of boolean clauses.exists()
Match documents where a given field exists.Create a DSL step allowing multiple attempts to apply extensions one after the other, failing only if none of the extensions is supported.knn
(int k) Matchk
documents whose vector field value is nearest to the given vector.match()
Match documents where targeted fields have a value that "matches" a given single value.matchAll()
Match all documents.nested()
Deprecated.Match documents where anested object
matches inner predicates to be defined in the next steps.default NestedPredicateClausesStep
<SR, ?> nested
(NestedPredicateFieldReference<? super SR> fieldReference) Match documents where anested object
matches inner predicates to be defined in the next steps.or()
Match documents if they match any inner clause.phrase()
Match documents where targeted fields have a value that contains a given phrase.prefix()
Match documents where targeted fields have a value that starts with a given string.Match documents according to a given query string, using the Lucene's query language.range()
Match documents where targeted fields have a value within lower and upper bounds.regexp()
Match documents where targeted fields contain a term that matches a given regular expression.Match documents according to a given query string, with a simple query language adapted to end users.spatial()
Access the different types of spatial predicates.terms()
Match documents where targeted fields contain a term that matches some terms of a given series of terms.toAbsolutePath
(String relativeFieldPath) wildcard()
Match documents where targeted fields contain a term that matches a given pattern, such asinter*on
orpa?t
.Create a new predicate factory whose root for all paths passed to the DSL will be the given object field.
-
Method Details
-
matchAll
MatchAllPredicateOptionsStep<SR,?> matchAll()Match all documents.- Specified by:
matchAll
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "match all" predicate can be defined.
- See Also:
-
bool
BooleanPredicateClausesStep<SR,?> bool()Match documents if they match a combination of boolean clauses.- Specified by:
bool
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "boolean" predicate can be defined.
- See Also:
-
and
SimpleBooleanPredicateClausesStep<SR,?> and()Match documents if they match all inner clauses.- Specified by:
and
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where predicates that must match can be added and options can be set.
- See Also:
-
or
SimpleBooleanPredicateClausesStep<SR,?> or()Match documents if they match any inner clause.- Specified by:
or
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where predicates that should match can be added and options can be set.
- See Also:
-
match
MatchPredicateFieldStep<SR,?> 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.
- Specified by:
match
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "match" predicate can be defined.
- See Also:
-
range
RangePredicateFieldStep<SR,?> range()Match documents where targeted fields have a value within lower and upper bounds.- Specified by:
range
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "range" predicate can be defined.
- See Also:
-
phrase
PhrasePredicateFieldStep<SR,?> phrase()Match documents where targeted fields have a value that contains a given phrase.- Specified by:
phrase
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "phrase" predicate can be defined.
- See Also:
-
wildcard
WildcardPredicateFieldStep<SR,?> 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, ...).
- Specified by:
wildcard
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "wildcard" predicate can be defined.
- See Also:
-
prefix
PrefixPredicateFieldStep<SR,?> prefix()Match documents where targeted fields have a value that starts with a given string.- Specified by:
prefix
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "prefix" predicate can be defined.
- See Also:
-
regexp
RegexpPredicateFieldStep<SR,?> regexp()Match documents where targeted fields contain a term that matches a given regular expression.- Specified by:
regexp
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "regexp" predicate can be defined.
- See Also:
-
terms
TermsPredicateFieldStep<SR,?> terms()Match documents where targeted fields contain a term that matches some terms of a given series of terms.- Specified by:
terms
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "terms" predicate can be defined.
- See Also:
-
nested
Deprecated.Usenested(String)
instead.Match documents where anested object
matches a given predicate.- Specified by:
nested
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "nested" predicate can be defined.
- See Also:
-
nested
Match documents where anested object
matches inner predicates to be defined in the next steps.The resulting nested predicate must match all inner clauses, similarly to an
"and" predicate
.- Specified by:
nested
in interfaceSearchPredicateFactory
- Parameters:
objectFieldPath
- The path to the (nested) object field that must match.- Returns:
- The initial step of a DSL where the "nested" predicate can be defined.
- See Also:
-
nested
default NestedPredicateClausesStep<SR,?> nested(NestedPredicateFieldReference<? super SR> fieldReference) Match documents where anested object
matches inner predicates to be defined in the next steps.The resulting nested predicate must match all inner clauses, similarly to an
"and" predicate
.- Parameters:
fieldReference
- The field reference representing a definition of the object field to apply the predicate on.- Returns:
- The initial step of a DSL where the "nested" predicate can be defined.
- See Also:
-
simpleQueryString
SimpleQueryStringPredicateFieldStep<SR,?> 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
CommonQueryStringPredicateOptionsStep.defaultOperator(BooleanOperator)
to change this behavior.- Specified by:
simpleQueryString
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "simple query string" predicate can be defined.
- See Also:
-
queryString
QueryStringPredicateFieldStep<SR,?> queryString()Match documents according to a given query string, using the Lucene's query language.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
CommonQueryStringPredicateOptionsStep.defaultOperator(BooleanOperator)
to change this behavior.- Specified by:
queryString
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "query string" predicate can be defined.
- See Also:
-
exists
ExistsPredicateFieldStep<SR,?> 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.
- Specified by:
exists
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where the "exists" predicate can be defined.
- See Also:
-
spatial
SpatialPredicateInitialStep<SR> spatial()Access the different types of spatial predicates.- Specified by:
spatial
in interfaceSearchPredicateFactory
- Returns:
- The initial step of a DSL where spatial predicates can be defined.
- See Also:
-
knn
Matchk
documents whose vector field value is nearest to the given vector."knn" stands for "K-Nearest Neighbors"; it is a form of vector search.
- Specified by:
knn
in interfaceSearchPredicateFactory
- Parameters:
k
- The number of nearest neighbors to look for.- Returns:
- The initial step of a DSL where knn predicate options can be defined.
- See Also:
-
extension
SearchPredicateFactoryExtensionIfSupportedStep<SR> 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
SearchPredicateFactory.extension(TypedSearchPredicateFactoryExtension)
method instead.- Specified by:
extension
in interfaceSearchPredicateFactory
- Returns:
- A DSL step.
-
withRoot
Create a new predicate factory whose root for all paths passed to the DSL will be the given object field.This is used to call reusable methods that apply the same predicate on different object fields that have same structure (same sub-fields).
- Specified by:
withRoot
in interfaceSearchPredicateFactory
- Parameters:
objectFieldPath
- The path from the current root to an object field that will become the new root.- Returns:
- A new predicate factory using the given object field as root.
-
toAbsolutePath
- Specified by:
toAbsolutePath
in interfaceSearchPredicateFactory
- Parameters:
relativeFieldPath
- The path to a field, relative to theroot
of this factory.- Returns:
- The absolute path of the field, for use in native predicates for example. Note the path is returned even if the field doesn't exist.
-
nested(String)
instead.