Class AbstractSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,R,E>,SC extends SearchProjectionIndexScope<?>,R,E>
- All Implemented Interfaces:
ExtendedSearchProjectionFactory<S,
,R, E> SearchProjectionFactory<R,
E>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionStarts the definition of a composite projection, which will combine multiple given projections.composite
(SearchProjection<?>... projections) Create a projection that will compose aList
based on the given projections.<T> ProjectionFinalStep<T>
constant
(T value) Project to a given constant.Project on the distance from the center to aGeoPoint
field.Project the match to aDocumentReference
.entity()
Project to the entity that was originally indexed.<T> EntityProjectionOptionsStep<?,
T> Project to the entity that was originally indexed.Project to a reference to the entity that was originally indexed.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
(SearchProjectionFactoryExtension<T, R, E> extension) Extend the current factory with the given extension, resulting in an extended factory offering different types of projections.<T> FieldProjectionValueStep<?,
T> field
(String fieldPath, Class<T> clazz, ValueConvert convert) Project to the value of a field in the indexed document.field
(String fieldPath, ValueConvert convert) Project to the value of a field in the indexed document, without specifying a type.Project to highlights, i.e.<I> IdProjectionOptionsStep<?,
I> Project to the identifier of the referenced entity, i.e.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).score()
Project on the score of the hit.final String
toAbsolutePath
(String relativeFieldPath) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.hibernate.search.engine.search.projection.dsl.ExtendedSearchProjectionFactory
withRoot
-
Field Details
-
dslContext
-
-
Constructor Details
-
AbstractSearchProjectionFactory
-
-
Method Details
-
documentReference
Description copied from interface:SearchProjectionFactory
Project the match to aDocumentReference
.- Specified by:
documentReference
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Returns:
- A DSL step where the "document reference" projection can be defined in more details.
-
field
public <T> FieldProjectionValueStep<?,T> field(String fieldPath, Class<T> clazz, ValueConvert convert) Description copied from interface:SearchProjectionFactory
Project to the value of a field in the indexed document.- Specified by:
field
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Type Parameters:
T
- The resulting type of the projection.- Parameters:
fieldPath
- The path to the index field whose value will be extracted.clazz
- The resulting type of the projection.convert
- Controls how the data fetched from the backend should be converted. SeeValueConvert
.- Returns:
- A DSL step where the "field" projection can be defined in more details.
-
field
Description copied from interface:SearchProjectionFactory
Project to the value of a field in the indexed document, without specifying a type.- Specified by:
field
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
fieldPath
- The path to the index field whose value will be extracted.convert
- Controls how the data fetched from the backend should be converted. SeeValueConvert
.- Returns:
- A DSL step where the "field" projection can be defined in more details.
-
entityReference
Description copied from interface:SearchProjectionFactory
Project to a reference to the entity that was originally indexed.Entity references are instances of type
EntityReference
, but some mappers may expose a different type for backwards compatibility reasons.EntityReference
should be favored wherever possible as mapper-specific types will eventually be removed.- Specified by:
entityReference
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Returns:
- A DSL step where the "entity reference" projection can be defined in more details.
-
id
Description copied from interface:SearchProjectionFactory
Project to the identifier of the referenced entity, i.e. the value of the property marked as@DocumentId
.- Specified by:
id
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Type Parameters:
I
- The requested type for returned identifiers.- Parameters:
requestedIdentifierType
- The requested type for returned identifiers. Must be exactly the type of identifiers of the entity types targeted by the search, or a supertype.- Returns:
- A DSL step where the "id" projection can be defined in more details.
-
entity
Description copied from interface:SearchProjectionFactory
Project to the entity that was originally indexed.The actual type of the entity depends on the mapper used to create the query and on the indexes targeted by your query: the Hibernate ORM mapper will return a managed entity loaded from the database, for example.
- Specified by:
entity
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Returns:
- A DSL step where the "entity" projection can be defined in more details.
-
entity
Description copied from interface:SearchProjectionFactory
Project to the entity that was originally indexed.The expected type will be checked against the actual type of the entity, which depends on the mapper used to create the query and on the indexes targeted by your query: the Hibernate ORM mapper will return a managed entity loaded from the database, for example.
- Specified by:
entity
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
requestedEntityType
- The requested type for returned entities. Must be exactly the type of entities targeted by the search, or a supertype.- Returns:
- A DSL step where the "entity" projection can be defined in more details.
-
score
Description copied from interface:SearchProjectionFactory
Project on the score of the hit.- Specified by:
score
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Returns:
- A DSL step where the "score" projection can be defined in more details.
-
distance
Description copied from interface:SearchProjectionFactory
Project on the distance from the center to aGeoPoint
field.- Specified by:
distance
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
fieldPath
- The path to 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
Description copied from interface:SearchProjectionFactory
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.- Specified by:
object
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
objectFieldPath
- The path to the object field whose object(s) will be extracted.- Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
composite
Description copied from interface:SearchProjectionFactory
Starts the definition of a composite projection, which will combine multiple given projections.On contrary to the
object projection
, a composite projection is not bound to a specific object field, and thus it will always yield one and only one value, regardless of whetherCompositeProjectionValueStep.multi()
is called.- Specified by:
composite
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
composite
Description copied from interface:SearchProjectionFactory
Create a projection that will compose aList
based on the given projections.- Specified by:
composite
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
projections
- The projections used to populate the list, in order.- Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
constant
Description copied from interface:SearchProjectionFactory
Project to a given constant.The projection will return the same value for every single hit.
- Specified by:
constant
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
value
- The constant value that the projection should return.- Returns:
- A DSL step where the "entity reference" projection can be defined in more details.
-
extension
Description copied from interface:SearchProjectionFactory
Extend the current factory with the given extension, resulting in an extended factory offering different types of projections.- Specified by:
extension
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Type Parameters:
T
- The type of factory provided by the extension.- Parameters:
extension
- The extension to the projection DSL.- Returns:
- The extended factory.
-
extension
Description copied from interface:SearchProjectionFactory
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<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Type Parameters:
T
- The expected projected type.- Returns:
- A DSL step.
-
toAbsolutePath
- Specified by:
toAbsolutePath
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
relativeFieldPath
- The path to a field, relative to theroot
of this factory.- Returns:
- The absolute path of the field, for use in native projections for example. Note the path is returned even if the field doesn't exist.
-
highlight
Description copied from interface:SearchProjectionFactory
Project to highlights, i.e. sequences of text that matched the query, extracted from the given field's value.- Specified by:
highlight
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,
R, E>, SC extends SearchProjectionIndexScope<?>> - Parameters:
fieldPath
- The path to the index field whose highlights will be extracted.- Returns:
- A DSL step where the "highlight" projection can be defined in more details.
-