Class FacetConfigurationApplyer
-
Constructor Summary
ConstructorsConstructorDescriptionFacetConfigurationApplyer
(SearchContext context, Set<Supplier<? extends CustomFacetCreator>> customFacetCreatorSupplier) -
Method Summary
Modifier and TypeMethodDescriptionList
<org.elasticsearch.search.aggregations.AggregationBuilder> buildAggregators
(FilterContext filterContext, int totalLimit) This method uses the initialized FacetCreators to build the right aggregations in respect of the active post filters.getFacets
(org.elasticsearch.search.aggregations.Aggregations aggregations, long matchCount, FilterContext filterContext, DefaultLinkBuilder linkBuilder)
-
Constructor Details
-
FacetConfigurationApplyer
public FacetConfigurationApplyer(SearchContext context, Set<Supplier<? extends CustomFacetCreator>> customFacetCreatorSupplier)
-
-
Method Details
-
buildAggregators
public List<org.elasticsearch.search.aggregations.AggregationBuilder> buildAggregators(FilterContext filterContext, int totalLimit) This method uses the initialized FacetCreators to build the right aggregations in respect of the active post filters.
Background / Details:For facets that should stay the same, even if one of its filters was selected ("multi-select-facets"), the post filtering feature is used. This way such facets can be created without their active filter. See Elasticsearch post filter documentation
However this leads to the problem, that other facets are also not filtered, although they should be. Otherwise they may present filters that lead to 0 results in combination with the active post filter/s.
The (only) solution is to apply the post filters for all those other aggregations as well, but of course not for the aggregation of the active post filter. This gets complicated if there are several post filters for different multi-select-facets. In that case each according aggregation needs to be filtered with the other post filters but not the related one.
Example:"brand" and "price" are configured to be multi-select-facets. If for both facets a filter is applied, the "brand" aggregation must consider the "price" filter and the "price" aggregation must consider the "brand" filter. All other aggregations must consider both post filters.
More details at http://stackoverflow.com/questions/41369749
- Parameters:
filterContext
- context that holds the filter queriestotalLimit
- the total amount of hits that are allowed to be in the result. Since Elasticsearch can't restrict that value with a query, we do that by using sampler aggregation.- Returns:
- list of filtered and/or unfiltered aggregation builders depending on the existance of post filters
-
getFacets
public List<Facet> getFacets(org.elasticsearch.search.aggregations.Aggregations aggregations, long matchCount, FilterContext filterContext, DefaultLinkBuilder linkBuilder)
-