R
- The type of references, i.e. the type of objects returned for reference projections
.O
- The type of loaded objects, i.e. the type of objects returned for
object projections
.public interface SearchProjectionFactoryContext<R,O>
Modifier and Type | Method and Description |
---|---|
<P1,P2,T> CompositeProjectionContext<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.
|
default <P1,P2,T> CompositeProjectionContext<T> |
composite(BiFunction<P1,P2,T> transformer,
SearchProjectionTerminalContext<P1> terminalContext1,
SearchProjectionTerminalContext<P2> terminalContext2)
Create a projection that will compose a custom object based on two almost-built projections.
|
<T> CompositeProjectionContext<T> |
composite(Function<List<?>,T> transformer,
SearchProjection<?>... projections)
Create a projection that will compose a custom object based on the given projections.
|
default <T> CompositeProjectionContext<T> |
composite(Function<List<?>,T> transformer,
SearchProjectionTerminalContext<?>... terminalContexts)
Create a projection that will compose a custom object based on the given almost-built projections.
|
<P,T> CompositeProjectionContext<T> |
composite(Function<P,T> transformer,
SearchProjection<P> projection)
Create a projection that will compose a custom object based on one given projection.
|
default <P,T> CompositeProjectionContext<T> |
composite(Function<P,T> transformer,
SearchProjectionTerminalContext<P> terminalContext)
Create a projection that will compose a custom object based on one almost-built projection.
|
default CompositeProjectionContext<List<?>> |
composite(SearchProjection<?>... projections)
Create a projection that will compose a
List based on the given projections. |
default CompositeProjectionContext<List<?>> |
composite(SearchProjectionTerminalContext<?>... terminalContexts)
Create a projection that will compose a
List based on the given almost-built projections. |
<P1,P2,P3,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.
|
default <P1,P2,P3,T> |
composite(TriFunction<P1,P2,P3,T> transformer,
SearchProjectionTerminalContext<P1> terminalContext1,
SearchProjectionTerminalContext<P2> terminalContext2,
SearchProjectionTerminalContext<P3> terminalContext3)
Create a projection that will compose a custom object based on three almost-built projections.
|
DistanceToFieldProjectionContext |
distance(String absoluteFieldPath,
GeoPoint center)
Project on the distance from the center to a
GeoPoint field. |
DocumentReferenceProjectionContext |
documentReference()
Project the match to a
DocumentReference . |
<T> SearchProjectionFactoryExtensionContext<T,R,O> |
extension()
Create a context allowing to try to apply multiple extensions one after the other,
failing only if none of the extensions is supported.
|
<T> T |
extension(SearchProjectionFactoryContextExtension<T,R,O> extension)
Extend the current context with the given extension,
resulting in an extended context offering different types of projections.
|
FieldProjectionContext<Object> |
field(String absoluteFieldPath)
Project to a field of the indexed document without specifying a type.
|
<T> FieldProjectionContext<T> |
field(String absoluteFieldPath,
Class<T> type)
Project to a field of the indexed document.
|
ObjectProjectionContext<O> |
object()
Project to an object representing the match.
|
ReferenceProjectionContext<R> |
reference()
Project to a reference to the match.
|
ScoreProjectionContext |
score()
Project on the score of the hit.
|
DocumentReferenceProjectionContext documentReference()
DocumentReference
.ReferenceProjectionContext<R> reference()
The actual type of the reference depends on the mapper used to create the query: a POJO mapper may return a class/identifier couple, for example.
ObjectProjectionContext<O> object()
The actual type of the object depends on the entry point
for your query: an IndexManager
will return a Java representation of the document,
but a mapper may return a Java representation of the mapped object.
<T> FieldProjectionContext<T> field(String absoluteFieldPath, Class<T> type)
T
- The resulting type of the projection.absoluteFieldPath
- The absolute path of the field.type
- The resulting type of the projection.FieldProjectionContext<Object> field(String absoluteFieldPath)
absoluteFieldPath
- The absolute path of the field.ScoreProjectionContext score()
DistanceToFieldProjectionContext distance(String absoluteFieldPath, GeoPoint center)
GeoPoint
field.default CompositeProjectionContext<List<?>> composite(SearchProjection<?>... projections)
List
based on the given projections.projections
- The projections used to populate the list, in order.default CompositeProjectionContext<List<?>> composite(SearchProjectionTerminalContext<?>... terminalContexts)
List
based on the given almost-built projections.terminalContexts
- The terminal contexts allowing to retrieve SearchProjection
s.<T> CompositeProjectionContext<T> composite(Function<List<?>,T> transformer, SearchProjection<?>... projections)
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.default <T> CompositeProjectionContext<T> composite(Function<List<?>,T> transformer, SearchProjectionTerminalContext<?>... terminalContexts)
transformer
- The function that will transform the projected element into a custom object.terminalContexts
- The terminal contexts allowing to retrieve SearchProjection
s.<P,T> CompositeProjectionContext<T> composite(Function<P,T> transformer, SearchProjection<P> projection)
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.default <P,T> CompositeProjectionContext<T> composite(Function<P,T> transformer, SearchProjectionTerminalContext<P> terminalContext)
transformer
- The function that will transform the projected element into a custom object.terminalContext
- The terminal context allowing to retrieve the SearchProjection
that will be used to produce the element passed to the transformer.<P1,P2,T> CompositeProjectionContext<T> composite(BiFunction<P1,P2,T> transformer, SearchProjection<P1> projection1, SearchProjection<P2> projection2)
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.default <P1,P2,T> CompositeProjectionContext<T> composite(BiFunction<P1,P2,T> transformer, SearchProjectionTerminalContext<P1> terminalContext1, SearchProjectionTerminalContext<P2> terminalContext2)
transformer
- The function that will transform the projected elements into a custom object.terminalContext1
- The terminal context allowing to retrieve the SearchProjection
that will be used to produce the first element passed to the transformer.terminalContext2
- The terminal context allowing to retrieve the SearchProjection
that will be used to produce the second element passed to the transformer.<P1,P2,P3,T> CompositeProjectionContext<T> composite(TriFunction<P1,P2,P3,T> transformer, SearchProjection<P1> projection1, SearchProjection<P2> projection2, SearchProjection<P3> projection3)
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.default <P1,P2,P3,T> CompositeProjectionContext<T> composite(TriFunction<P1,P2,P3,T> transformer, SearchProjectionTerminalContext<P1> terminalContext1, SearchProjectionTerminalContext<P2> terminalContext2, SearchProjectionTerminalContext<P3> terminalContext3)
transformer
- The function that will transform the projected elements into a custom object.terminalContext1
- The terminal context allowing to retrieve the SearchProjection
that will be used to produce the first element passed to the transformer.terminalContext2
- The terminal context allowing to retrieve the SearchProjection
that will be used to produce the second element passed to the transformer.terminalContext3
- The terminal context allowing to retrieve the SearchProjection
that will be used to produce the third element passed to the transformer.<T> T extension(SearchProjectionFactoryContextExtension<T,R,O> extension)
T
- The type of context provided by the extension.extension
- The extension to the projection DSL.SearchException
- If the extension cannot be applied (wrong underlying backend, ...).<T> SearchProjectionFactoryExtensionContext<T,R,O> extension()
If you only need to apply a single extension and fail if it is not supported,
use the simpler extension(SearchProjectionFactoryContextExtension)
method instead.
This method is generic, and you should set the generic type explicitly to the expected projected type,
e.g. .<MyProjectedType>extension()
.
T
- The expected projected type.Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.