N - The next context if no type of hits is explicitly selected,
i.e. if SearchQueryResultContext.predicate(SearchPredicate) or SearchQueryResultContext.predicate(Function) is called directly
without calling asEntity(), or asReference(), asProjection(SearchProjection)
or a similar method.R - The type of references, i.e. the type of hits returned by
reference queries,
or the type of objects returned for reference projections.E - The type of entities, i.e. the type of hits returned by
entity queries,
or the type of objects returned for entity projections.PJC - The type of contexts used to create projections in asProjection(Function).PDC - The type of contexts used to create predicates in SearchQueryResultContext.predicate(Function).public interface SearchQueryResultDefinitionContext<N extends SearchQueryContext<?,E,?>,R,E,PJC extends SearchProjectionFactoryContext<R,E>,PDC extends SearchPredicateFactoryContext> extends SearchQueryResultContext<N,E,PDC>
| Modifier and Type | Method and Description |
|---|---|
SearchQueryResultContext<?,E,?> |
asEntity()
Define the query results as the entity was originally indexed, loaded from an external source (database, ...).
|
<P> SearchQueryResultContext<?,P,?> |
asProjection(Function<? super PJC,? extends SearchProjectionTerminalContext<P>> projectionContributor)
Define the query results as one projection for each matching document.
|
<P> SearchQueryResultContext<?,P,?> |
asProjection(SearchProjection<P> projection)
Define the query results as one projection for each matching document.
|
SearchQueryResultContext<?,List<?>,?> |
asProjections(SearchProjection<?>... projections)
Define the query results as a list of projections for each matching document.
|
SearchQueryResultContext<?,R,?> |
asReference()
Define the query results as a reference to entity that was originally indexed.
|
<T> T |
extension(SearchQueryContextExtension<T,R,E> extension)
Extend the current context with the given extension,
resulting in an extended context offering more query options.
|
predicate, predicateSearchQueryResultContext<?,E,?> asEntity()
SearchQueryResultContextSearchQueryResultContext<?,R,?> asReference()
SearchQueryResultContext<P> SearchQueryResultContext<?,P,?> asProjection(Function<? super PJC,? extends SearchProjectionTerminalContext<P>> projectionContributor)
P - The resulting type of the projection.projectionContributor - A function that will use the DSL context passed in parameter to create a projection,
returning the resulting terminal context.
Should generally be a lambda expression.SearchQueryResultContext<P> SearchQueryResultContext<?,P,?> asProjection(SearchProjection<P> projection)
P - The resulting type of the projection.projection - A previously-created SearchProjection object.SearchQueryResultContextSearchQueryResultContext<?,List<?>,?> asProjections(SearchProjection<?>... projections)
Note that using this method will force you to use casts when consuming the results,
since the returned lists are not typed (List<?> instead of List<T>).
You can replace calls to this method advantageously with calls to asProjection(Function)
defining a composite projection.
projections - A list of previously-created SearchProjection objects.SearchProjectionFactoryContext.composite(BiFunction, SearchProjection, SearchProjection),
SearchQueryResultContext<T> T extension(SearchQueryContextExtension<T,R,E> extension)
T - The type of context provided by the extension.extension - The extension to the predicate DSL.SearchException - If the extension cannot be applied (wrong underlying backend, ...).Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.