Class AbstractSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,R,E>,SC extends SearchProjectionIndexScope<?>,R,E>
- java.lang.Object
-
- org.hibernate.search.engine.search.projection.dsl.spi.AbstractSearchProjectionFactory<S,SC,R,E>
-
- All Implemented Interfaces:
ExtendedSearchProjectionFactory<S,R,E>
,SearchProjectionFactory<R,E>
public abstract class AbstractSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,R,E>,SC extends SearchProjectionIndexScope<?>,R,E> extends Object implements ExtendedSearchProjectionFactory<S,R,E>
-
-
Field Summary
Fields Modifier and Type Field Description protected SearchProjectionDslContext<SC>
dslContext
-
Constructor Summary
Constructors Constructor Description AbstractSearchProjectionFactory(SearchProjectionDslContext<SC> dslContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <P1,P2,T>
CompositeProjectionOptionsStep<?,T>composite(BiFunction<P1,P2,T> transformer, SearchProjection<P1> projection1, SearchProjection<P2> projection2)
Create a projection that will compose a custom object based on two given projections.<T> CompositeProjectionOptionsStep<?,T>
composite(Function<List<?>,T> transformer, SearchProjection<?>... projections)
Create a projection that will compose a custom object based on the given projections.<P,T>
CompositeProjectionOptionsStep<?,T>composite(Function<P,T> transformer, SearchProjection<P> projection)
Create a projection that will compose a custom object based on one given projection.<P1,P2,P3,T>
CompositeProjectionOptionsStep<?,T>composite(TriFunction<P1,P2,P3,T> transformer, SearchProjection<P1> projection1, SearchProjection<P2> projection2, SearchProjection<P3> projection3)
Create a projection that will compose a custom object based on three given projections.DistanceToFieldProjectionValueStep<?,Double>
distance(String fieldPath, GeoPoint center)
Project on the distance from the center to aGeoPoint
field.DocumentReferenceProjectionOptionsStep<?>
documentReference()
Project the match to aDocumentReference
.EntityProjectionOptionsStep<?,E>
entity()
Project to the entity was originally indexed.EntityReferenceProjectionOptionsStep<?,R>
entityReference()
Project to a reference to the entity that was originally indexed.<T> SearchProjectionFactoryExtensionIfSupportedStep<T,R,E>
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(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.FieldProjectionValueStep<?,Object>
field(String fieldPath, ValueConvert convert)
Project to the value of a field in the indexed document, without specifying a type.<I> IdProjectionOptionsStep<?,I>
id(Class<I> identifierType)
Project to the identifier of the referenced entity, i.e.ScoreProjectionOptionsStep<?>
score()
Project on the score of the hit.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 Detail
-
dslContext
protected final SearchProjectionDslContext<SC extends SearchProjectionIndexScope<?>> dslContext
-
-
Constructor Detail
-
AbstractSearchProjectionFactory
public AbstractSearchProjectionFactory(SearchProjectionDslContext<SC> dslContext)
-
-
Method Detail
-
documentReference
public DocumentReferenceProjectionOptionsStep<?> 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
public FieldProjectionValueStep<?,Object> field(String fieldPath, ValueConvert convert)
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
public EntityReferenceProjectionOptionsStep<?,R> entityReference()
Description copied from interface:SearchProjectionFactory
Project to a reference to the entity that was originally indexed.The actual type of the reference depends on the mapper used to create the query: the ORM mapper will return a class/identifier pair, for example.
- 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
public <I> IdProjectionOptionsStep<?,I> id(Class<I> identifierType)
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 expected type of the identifier- Parameters:
identifierType
- The expected type of the identifier- Returns:
- A DSL step where the "id" projection can be defined in more details.
-
entity
public EntityProjectionOptionsStep<?,E> entity()
Description copied from interface:SearchProjectionFactory
Project to the entity 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 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.
-
score
public ScoreProjectionOptionsStep<?> 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
public DistanceToFieldProjectionValueStep<?,Double> distance(String fieldPath, GeoPoint center)
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.
-
composite
public <T> CompositeProjectionOptionsStep<?,T> composite(Function<List<?>,T> transformer, SearchProjection<?>... projections)
Description copied from interface:SearchProjectionFactory
Create a projection that will compose a custom object based on the given projections.- Specified by:
composite
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,R,E>,SC extends SearchProjectionIndexScope<?>>
- Type Parameters:
T
- The type of the custom object composing the projected elements.- Parameters:
transformer
- The function that will transform the list of projected elements into a custom object.projections
- The projections used to populate the list, in order.- Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
composite
public <P,T> CompositeProjectionOptionsStep<?,T> composite(Function<P,T> transformer, SearchProjection<P> projection)
Description copied from interface:SearchProjectionFactory
Create a projection that will compose a custom object based on one given projection.- Specified by:
composite
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,R,E>,SC extends SearchProjectionIndexScope<?>>
- Type Parameters:
P
- The type of the element passed to the transformer.T
- The type of the custom object composing the projected element.- Parameters:
transformer
- The function that will transform the projected element into a custom object.projection
- The original projection used to produce the element passed to the transformer.- Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
composite
public <P1,P2,T> CompositeProjectionOptionsStep<?,T> composite(BiFunction<P1,P2,T> transformer, SearchProjection<P1> projection1, SearchProjection<P2> projection2)
Description copied from interface:SearchProjectionFactory
Create a projection that will compose a custom object based on two given projections.- Specified by:
composite
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,R,E>,SC extends SearchProjectionIndexScope<?>>
- Type Parameters:
P1
- The type of the first element passed to the transformer.P2
- The type of the second element passed to the transformer.T
- The type of the custom object composing the projected elements.- Parameters:
transformer
- The function that will transform the projected elements into a custom object.projection1
- The projection used to produce the first element passed to the transformer.projection2
- The projection used to produce the second element passed to the transformer.- Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
composite
public <P1,P2,P3,T> CompositeProjectionOptionsStep<?,T> composite(TriFunction<P1,P2,P3,T> transformer, SearchProjection<P1> projection1, SearchProjection<P2> projection2, SearchProjection<P3> projection3)
Description copied from interface:SearchProjectionFactory
Create a projection that will compose a custom object based on three given projections.- Specified by:
composite
in interfaceSearchProjectionFactory<S extends ExtendedSearchProjectionFactory<S,R,E>,SC extends SearchProjectionIndexScope<?>>
- Type Parameters:
P1
- The type of the first element passed to the transformer.P2
- The type of the second element passed to the transformer.P3
- The type of the third element passed to the transformer.T
- The type of the custom object composing the projected elements.- Parameters:
transformer
- The function that will transform the projected elements into a custom object.projection1
- The projection used to produce the first element passed to the transformer.projection2
- The projection used to produce the second element passed to the transformer.projection3
- The projection used to produce the third element passed to the transformer.- Returns:
- A DSL step where the "composite" projection can be defined in more details.
-
extension
public <T> T extension(SearchProjectionFactoryExtension<T,R,E> 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
public <T> SearchProjectionFactoryExtensionIfSupportedStep<T,R,E> 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
public final String toAbsolutePath(String relativeFieldPath)
- 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.
-
-