Package de.cxp.ocs.elasticsearch.facets
Class FixedIntervalFacetCreator
java.lang.Object
de.cxp.ocs.elasticsearch.facets.FixedIntervalFacetCreator
- All Implemented Interfaces:
CustomFacetCreator
The basis for a interval facet creator that should extract facets with fixed intervals.
Why is it not possible to have a configurable FixedIntervalFacetCreator? Because a single facet creator will be used for all facets it is configured for. So it is not possible to configure one FixedIntervalFacetCreator for different facets with different interval ranges.
That's why one would need to create for example a "RatingFacetCreator" and a "FixedPriceIntervalFacetCreator" with different ranges and different "custom facet types" to meet its requirements.
Unless "configurable single-use facet creators" are not supported, this is the (only?) way to support that kind of requirement with minimal effort.
- Author:
- rb@commerce-experts.com
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA restricted range to numeric values only. -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionorg.elasticsearch.search.aggregations.AggregationBuilderbuildAggregation(String fullFieldName) Build the (sub)-aggregation that should be applied on the values of each field with that facet-type.createFacet(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket facetNameBucket, FacetConfiguration.FacetConfig facetConfig, InternalResultFilter facetFilter, LinkBuilder linkBuilder, Function<org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket, Long> nestedValueBucketDocCountCorrector) Create a facet from the given aggregation result.protected FacetEntrycreateIntervalFacetEntry(NumericFacetEntryBuilder currentValueInterval, NumberResultFilter selectedFilter, FacetConfiguration.FacetConfig facetConfig, LinkBuilder linkBuilder) protected <T extends Number>
voidfillFacet(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket facetNameBucket, Facet facet, FacetConfiguration.FacetConfig facetConfig, LinkBuilder linkBuilder, NumberResultFilter selectedFilter, Function<org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket, Long> nestedValueBucketDocCountCorrector) Specify for which field type this creator works.protected StringmergeFacets(Facet first, Facet second) In case such a custom facet should be created on a field that is indexed on variant and master level, two facets are created and should be merged.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.cxp.ocs.spi.search.CustomFacetCreator
getFacetType
-
Constructor Details
-
FixedIntervalFacetCreator
-
-
Method Details
-
getAcceptibleFieldType
Description copied from interface:CustomFacetCreatorSpecify for which field type this creator works. Must be one of: STRING, NUMBER, CATEGORY. A facet creator can not work for different field types - in that case different implementation of the facet-creator with different- Specified by:
getAcceptibleFieldTypein interfaceCustomFacetCreator- Returns:
-
getUniqAggregationName
-
buildAggregation
public org.elasticsearch.search.aggregations.AggregationBuilder buildAggregation(String fullFieldName) Description copied from interface:CustomFacetCreatorBuild the (sub)-aggregation that should be applied on the values of each field with that facet-type. The same aggregation is used for all facets of that type.- Specified by:
buildAggregationin interfaceCustomFacetCreator- Parameters:
fullFieldName- the 'full value field name' to be used as aggregation field-name.- Returns:
-
createFacet
public Optional<Facet> createFacet(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket facetNameBucket, FacetConfiguration.FacetConfig facetConfig, InternalResultFilter facetFilter, LinkBuilder linkBuilder, Function<org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket, Long> nestedValueBucketDocCountCorrector) Description copied from interface:CustomFacetCreatorCreate a facet from the given aggregation result.- Specified by:
createFacetin interfaceCustomFacetCreator- Parameters:
facetNameBucket- The terms bucket of that facet field. The key of that bucket is the field name. It contains the required aggregation results as sub-aggregation.facetConfig- the config of the facet to be createdfacetFilter- a nullable filter if there is a filter applied for facet. Necessary to set the according values as selected.linkBuilder- a helper to create links for facet values / filters.- Returns:
- facet if it can be created otherwise an empty optional.
-
fillFacet
protected <T extends Number> void fillFacet(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket facetNameBucket, Facet facet, FacetConfiguration.FacetConfig facetConfig, LinkBuilder linkBuilder, NumberResultFilter selectedFilter, Function<org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket, Long> nestedValueBucketDocCountCorrector) -
createIntervalFacetEntry
protected FacetEntry createIntervalFacetEntry(NumericFacetEntryBuilder currentValueInterval, NumberResultFilter selectedFilter, FacetConfiguration.FacetConfig facetConfig, LinkBuilder linkBuilder) -
mergeFacets
Description copied from interface:CustomFacetCreatorIn case such a custom facet should be created on a field that is indexed on variant and master level, two facets are created and should be merged. If that is not possible feel free to log an error and return Optional.empty or just one of those facets.- Specified by:
mergeFacetsin interfaceCustomFacetCreator- Parameters:
first-second-- Returns:
-