Class CategoryFacetCreator
- All Implemented Interfaces:
FacetCreator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
protected static class
-
Field Summary
Fields inherited from class de.cxp.ocs.elasticsearch.facets.NestedFacetCreator
nestedFacetCorrector
-
Constructor Summary
ConstructorsConstructorDescriptionCategoryFacetCreator
(Map<String, FacetConfiguration.FacetConfig> facetConfigs, Function<String, FacetConfiguration.FacetConfig> defaultFacetConfigProvider) CategoryFacetCreator
(Map<String, FacetConfiguration.FacetConfig> facetConfigs, Function<String, FacetConfiguration.FacetConfig> defaultFacetConfigProvider, boolean isExplicitFacetCreator) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
createFacet
(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket facetNameBucket, FacetConfiguration.FacetConfig facetConfig, InternalResultFilter intFacetFilter, DefaultLinkBuilder linkBuilder) 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.protected String
protected org.elasticsearch.search.aggregations.AggregationBuilder
getNestedValueAggregation
(String nestedPathPrefix) protected boolean
isMatchingFilterType
(InternalResultFilter internalResultFilter) protected String
joinPartialPath
(String[] pathValues, int endIndex) mergeFacets
(Facet a, Facet b) Try to merge facets with same label.protected boolean
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.Methods inherited from class de.cxp.ocs.elasticsearch.facets.NestedFacetCreator
buildAggregation, buildExcludeFilteredAggregation, buildIncludeFilteredAggregation, createFacets, extractFacets
-
Constructor Details
-
CategoryFacetCreator
public CategoryFacetCreator(Map<String, FacetConfiguration.FacetConfig> facetConfigs, Function<String, FacetConfiguration.FacetConfig> defaultFacetConfigProvider) -
CategoryFacetCreator
public CategoryFacetCreator(Map<String, FacetConfiguration.FacetConfig> facetConfigs, Function<String, FacetConfiguration.FacetConfig> defaultFacetConfigProvider, boolean isExplicitFacetCreator)
-
-
Method Details
-
getNestedPath
- Specified by:
getNestedPath
in classNestedFacetCreator
-
getNestedValueAggregation
protected org.elasticsearch.search.aggregations.AggregationBuilder getNestedValueAggregation(String nestedPathPrefix) - Specified by:
getNestedValueAggregation
in classNestedFacetCreator
-
onlyFetchAggregationsForConfiguredFacets
protected boolean onlyFetchAggregationsForConfiguredFacets()- Specified by:
onlyFetchAggregationsForConfiguredFacets
in classNestedFacetCreator
-
correctedNestedDocumentCount
protected boolean correctedNestedDocumentCount()- Specified by:
correctedNestedDocumentCount
in classNestedFacetCreator
-
isMatchingFilterType
- Specified by:
isMatchingFilterType
in classNestedFacetCreator
-
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 classNestedFacetCreator
-
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
-
mergeFacets
Description copied from interface:FacetCreator
Try to merge facets with same label. If not possible, return Optional.empty.- Parameters:
a
- Facet Ab
- Facet B- Returns:
- optionally a merged Facet, otherwise Optional::empty
-