Class HeroProductHandler

java.lang.Object
de.cxp.ocs.elasticsearch.prodset.HeroProductHandler

public class HeroProductHandler extends Object
Hero products that should be displayed at the top of the result, come with several uncomfortable requirements. This class helps to handle all of them:
  • hero products should also be reflected by the facets, so follow up requests with filters should also remove non-matching hero products. Result counts and facet counts of course should reflect this behavior.
  • hero products should also be under the control of result-pages. This is especially important if the page-size/result limit is lower than the amount of hero products!
  • If several sets of hero products are defined, make sure the same product does not appear in more that one.
  • Multiple hero product sets should return in the order as they have been requested
  • Static product sets and dynamic product sets with sorting should return the single hits in the order they have been requested.
Author:
Rudolf Batt
  • Field Details

    • QUERY_NAME_PREFIX

      public static String QUERY_NAME_PREFIX
  • Constructor Details

  • Method Details

    • resolve

      public StaticProductSet[] resolve(ProductSet[] productSets, Searcher searcher, SearchContext searchContext)
      Resolve the given product sets into static product sets. For given static product sets, the specified IDs are verified. For dynamic product sets, the matching IDs are fetched.
      Parameters:
      productSets - array of product sets to be resolved to static product sets
      searcher - matching Searcher instance for these products
      searchContext - context
      Returns:
      array of resolved product sets
    • getHeroQuery

      public static Optional<HeroProductsQuery> getHeroQuery(InternalSearchParams internalParams)
    • extractSlices

      public static Set<String> extractSlices(org.elasticsearch.action.search.SearchResponse searchResponse, InternalSearchParams internalParams, SearchResult searchResult, VariantPickingStrategy variantPickingStrategy)

      Extract the hero products into separate ordered slices, that are attached to the searchResult.

      In case the result was sorted or filtered, this method most likely won't extract slices anymore, because it expects them in the defined order at the top of the result.

      Parameters:
      searchResponse - ES search result
      internalParams - with sortings and hero product-sets
      searchResult - where hero product slices should be added
      variantPickingStrategy - function to pick variant in case of inner variant hits
      Returns:
      set of ids, that are already part of primary slices