Interface ElasticsearchSearchProjection.Extractor<E,P>
- Type Parameters:
E- The type of temporary values extracted from the response. May be the same asElasticsearchSearchProjection.Extractor, or not, depending on implementation.P- The type of projected values.
- All Known Implementing Classes:
ElasticsearchConstantProjection,ElasticsearchDistanceToFieldProjection,ElasticsearchEntityLoadingProjection,ElasticsearchEntityReferenceProjection,ElasticsearchIdProjection,ElasticsearchThrowingProjection
- Enclosing interface:
- ElasticsearchSearchProjection<P>
public static interface ElasticsearchSearchProjection.Extractor<E,P>
An object responsible for extracting data from the Elasticsearch response,
to implement a projection.
-
Method Summary
Modifier and TypeMethodDescriptionextract(ProjectionHitMapper<?> projectionHitMapper, com.google.gson.JsonObject hit, com.google.gson.JsonObject source, ProjectionExtractContext context) Performs hit extraction.transform(LoadingResult<?> loadingResult, E extractedData, ProjectionTransformContext context) Transforms the extracted data to the actual projection result.static <Z> ZtransformUnsafe(ElasticsearchSearchProjection.Extractor<?, Z> extractor, LoadingResult<?> loadingResult, Object extractedData, ProjectionTransformContext context) Transforms the extracted data and casts it to the right type.
-
Method Details
-
extract
E extract(ProjectionHitMapper<?> projectionHitMapper, com.google.gson.JsonObject hit, com.google.gson.JsonObject source, ProjectionExtractContext context) Performs hit extraction.Implementations should only perform operations relative to extracting content from the index, delaying operations that rely on the mapper until
transform(LoadingResult, Object, ProjectionTransformContext)is called, so that blocking mapper operations (if any) do not pollute backend threads.- Parameters:
projectionHitMapper- The projection hit mapper used to transform hits to entities.hit- The part of the response body relevant to the hit to extract.source- The part of the source that this extractor should extract from (if relevant).context- An execution context for the extraction.- Returns:
- The element extracted from the hit. Might be a key referring to an object that will be loaded by the
ProjectionHitMapper. This returned object will be passed totransform(LoadingResult, Object, ProjectionTransformContext).
-
transform
Transforms the extracted data to the actual projection result.- Parameters:
loadingResult- Container containing all the entities that have been loaded by theProjectionHitMapper.extractedData- The extracted data to transform, coming from theextract(ProjectionHitMapper, JsonObject, JsonObject, ProjectionExtractContext)method.context- An execution context for the transforming.- Returns:
- The final result considered as a hit.
-
transformUnsafe
static <Z> Z transformUnsafe(ElasticsearchSearchProjection.Extractor<?, Z> extractor, LoadingResult<?> loadingResult, Object extractedData, ProjectionTransformContext context) Transforms the extracted data and casts it to the right type.This should be used with care as it's unsafe.
-