Interface TypedSearchProjectionFactory<SR,R,E>
- Type Parameters:
SR
- Scope root type.R
- The type of entity references, i.e. the type of objects returned forentity reference projections
.E
- The type of entities, i.e. the type of objects returned forentity projections
.
- All Superinterfaces:
SearchProjectionFactory<R,
E>
- All Known Subinterfaces:
ElasticsearchSearchProjectionFactory<SR,
,R, E> ExtendedSearchProjectionFactory<SR,
,S, R, E> LuceneSearchProjectionFactory<SR,
R, E>
- All Known Implementing Classes:
AbstractSearchProjectionFactory
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 projection on different object fields that have same structure (same sub-fields).
Such a factory can also transform relative paths into absolute paths using SearchProjectionFactory.toAbsolutePath(String)
;
this can be useful for native projections in particular.
Field references
A field 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 TypeMethodDescriptiondefault DistanceToFieldProjectionValueStep
<?, Double> distance
(DistanceProjectionFieldReference<? super SR> fieldReference, GeoPoint center) Project on the distance from the center to aGeoPoint
field.Create a DSL step allowing multiple attempts to apply extensions one after the other, failing only if none of the extensions is supported.default <T> FieldProjectionValueStep
<?, T> field
(FieldProjectionFieldReference<? super SR, T> fieldReference) Project to the value of a field in the indexed document.default HighlightProjectionOptionsStep
highlight
(HighlightProjectionFieldReference<? super SR> fieldReference) Project to highlights, i.e. sequences of text that matched the query, extracted from the given field's value.default CompositeProjectionInnerStep
object
(ObjectFieldReference<? super SR> objectFieldReference) Starts the definition of an object projection, which will yield one value per object in a given object field, the value being the result of combining multiple given projections (usually on fields within the object field).Create a new projection factory whose root for all paths passed to the DSL will be the given object field.Methods inherited from interface org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory
composite, composite, composite, composite, composite, composite, composite, composite, composite, composite, composite, constant, distance, documentReference, entity, entity, entityReference, extension, field, field, field, field, field, field, highlight, id, id, object, score, toAbsolutePath, withParameters
-
Method Details
-
field
@Incubating default <T> FieldProjectionValueStep<?,T> field(FieldProjectionFieldReference<? super SR, T> fieldReference) Project to the value of a field in the indexed document.- Type Parameters:
T
- The resulting type of the projection.- Parameters:
fieldReference
- The field reference representing a definition of the index field whose value will be extracted.- Returns:
- A DSL step where the "field" projection can be defined in more details.
-
distance
@Incubating default DistanceToFieldProjectionValueStep<?,Double> distance(DistanceProjectionFieldReference<? super SR> fieldReference, GeoPoint center) Project on the distance from the center to aGeoPoint
field.- Parameters:
fieldReference
- The field reference representing a definition of the index field containing the location to compute the distance from.center
- The center to compute the distance from.- Returns:
- A DSL step where the "distance" projection can be defined in more details.
-
object
@Incubating default CompositeProjectionInnerStep object(ObjectFieldReference<? super SR> objectFieldReference) Starts the definition of an object projection, which will yield one value per object in a given object field, the value being the result of combining multiple given projections (usually on fields within the object field).Compared to the basic
composite projection
, an object projection is bound to a specific object field, and thus it yields zero, one or many values, as many as there are objects in the targeted object field. Therefore, you must take care of callingCompositeProjectionValueStep.multi()
if the object field is multi-valued.- Parameters:
objectFieldReference
- The field reference representing a definition of the index object field whose object(s) will be extracted.- Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
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
SearchProjectionFactory.extension(SearchProjectionFactoryExtension)
method instead.This method is generic, and you should set the generic type explicitly to the expected projected type, e.g.
.<MyProjectedType>extension()
.- Specified by:
extension
in interfaceSearchProjectionFactory<SR,
R> - Type Parameters:
T
- The expected projected type.- Returns:
- A DSL step.
-
withRoot
Create a new projection factory whose root for all paths passed to the DSL will be the given object field.This is used to call reusable methods that can apply the same projection on different object fields that have same structure (same sub-fields).
- Specified by:
withRoot
in interfaceSearchProjectionFactory<SR,
R> - Parameters:
objectFieldPath
- The path from the current root to an object field that will become the new root.- Returns:
- A new projection factory using the given object field as root.
-
highlight
@Incubating default HighlightProjectionOptionsStep highlight(HighlightProjectionFieldReference<? super SR> fieldReference) Project to highlights, i.e. sequences of text that matched the query, extracted from the given field's value.- Parameters:
fieldReference
- The field reference representing a definition of the index field whose highlights will be extracted.- Returns:
- A DSL step where the "highlight" projection can be defined in more details.
-