Package de.cxp.ocs.elasticsearch.mapper
Class ResultMapper
java.lang.Object
de.cxp.ocs.elasticsearch.mapper.ResultMapper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResultHit
mapSearchHit
(org.elasticsearch.search.SearchHit hit, Map<String, org.elasticsearch.search.sort.SortOrder> sortedFields) static ResultHit
mapSearchHit
(org.elasticsearch.search.SearchHit hit, Map<String, org.elasticsearch.search.sort.SortOrder> sortedFields, VariantPickingStrategy variantPickingStrategy) Extract a result document from the search-hit.static Document
mapToOriginalDocument
(String id, Map<String, Object> source, FieldConfigIndex fieldConfig)
-
Constructor Details
-
ResultMapper
public ResultMapper()
-
-
Method Details
-
mapSearchHit
-
mapSearchHit
public static ResultHit mapSearchHit(org.elasticsearch.search.SearchHit hit, Map<String, org.elasticsearch.search.sort.SortOrder> sortedFields, VariantPickingStrategy variantPickingStrategy) Extract a result document from the search-hit. This includes some extra logic for variant handling:- If sortedFields are given, then documents that have several values at
a sort field will get a "${fieldname}_prefix" field with the value
'{from}' (for asc order) or '{to}' (for desc order). Also according to
the sort order the according lowest or highest value is put into the
according field.
Example: With this behavior it is possible to show "from 10€" (for asc price sorting) or "to 59€" (for desc price sorting) for products that have several variants with different prices. -
The result-data of a variant is put into the document if one of the
following conditions met:
- the search hit only contains 1 variant
- the first variant has a better matching score than the second variant
- the 'preferVariantHits' flag is true
- Parameters:
hit
- ES search hitsortedFields
- map with field-to-sortOrder entries applicable on variant level (no validation done here)variantPickingStrategy
- function to pick variant in case of inner variant hits- Returns:
- mapped result hit
- If sortedFields are given, then documents that have several values at
a sort field will get a "${fieldname}_prefix" field with the value
'{from}' (for asc order) or '{to}' (for desc order). Also according to
the sort order the according lowest or highest value is put into the
according field.
-
mapToOriginalDocument
-