Class CategoryFacetCreator

java.lang.Object
de.cxp.ocs.elasticsearch.facets.NestedFacetCreator
de.cxp.ocs.elasticsearch.facets.CategoryFacetCreator
All Implemented Interfaces:
FacetCreator

public class CategoryFacetCreator extends NestedFacetCreator
  • Constructor Details

  • Method Details

    • getNestedPath

      protected String getNestedPath()
      Specified by:
      getNestedPath in class NestedFacetCreator
    • getNestedValueAggregation

      protected org.elasticsearch.search.aggregations.AggregationBuilder getNestedValueAggregation(String nestedPathPrefix)
      Specified by:
      getNestedValueAggregation in class NestedFacetCreator
    • onlyFetchAggregationsForConfiguredFacets

      protected boolean onlyFetchAggregationsForConfiguredFacets()
      Specified by:
      onlyFetchAggregationsForConfiguredFacets in class NestedFacetCreator
    • correctedNestedDocumentCount

      protected boolean correctedNestedDocumentCount()
      Specified by:
      correctedNestedDocumentCount in class NestedFacetCreator
    • isMatchingFilterType

      protected boolean isMatchingFilterType(InternalResultFilter internalResultFilter)
      Specified by:
      isMatchingFilterType in class NestedFacetCreator
    • createFacet

      protected Optional<Facet> createFacet(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket facetNameBucket, FacetConfiguration.FacetConfig facetConfig, InternalResultFilter intFacetFilter, DefaultLinkBuilder linkBuilder)
      Specified by:
      createFacet in class NestedFacetCreator
    • toFacetEntry

      protected HierarchialFacetEntry toFacetEntry(int categoryPathIndex, CategoryFacetCreator.CategoryExtract category, CategoryFacetCreator.CategoryContext context)
      Create the facet entry for the category defined by the categoryPathIndex that refers to the according path of the given CategoryExtract. The documentCount will be corrected afterwards.
      Parameters:
      categoryPathIndex - the index of the category inside the path for which a link should be created.
      category - the current full category. The actual category could be a parent of it.
      context - category context will all objects around this facet.
      Returns:
      the created facet entry
    • createLink

      protected String createLink(int categoryPathIndex, CategoryFacetCreator.CategoryExtract category, CategoryFacetCreator.CategoryContext context)
      Creates a link (using the context.linkBuilder) for the category defined by the categoryPathIndex that refers to the according path of the current category.

      The logic depends on the different settings and active filters:

      If "multi-select" is enabled, the filters unrelated to this path stay as is. The current path is then just appended as filter value. This is also the case for "siblings" of a selected path. This means sibling categories have a classic "multi-select behaviour".
      Parent elements of a selected path get a link that replaces the child filter by that parent filter. That means choosing a parent facet entry / filter, will remove the child-filter and select the parent.
      Same for child elements of a selected path: the active filter is replaced by that child path, which on the contrary to parent filters will reduce the result size.

      In case "multi-select" is disabled, each facet element will get a link that selects only that filter and removes other potential filters of that facet.
      Selected facet elements will receive a filter that removes all facet-filters completely.

      Parameters:
      categoryPathIndex - the index of the category inside the path for which a link should be created.
      category - the current full category. The actual category could be a parent of it.
      context - category context will all objects around this facet.
      Returns:
      the link as URL query part (e.g. "category.id=123&q=foo")
    • joinPartialPath

      protected String joinPartialPath(String[] pathValues, int endIndex)
    • mergeFacets

      public Optional<Facet> mergeFacets(Facet a, Facet b)
      Description copied from interface: FacetCreator
      Try to merge facets with same label. If not possible, return Optional.empty.
      Parameters:
      a - Facet A
      b - Facet B
      Returns:
      optionally a merged Facet, otherwise Optional::empty