Class FacetConfiguration.FacetConfig
- Enclosing class:
FacetConfiguration
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
setExcludeFromFacetLimit
(boolean excludeFromFacetLimit) If set to true, this facet will always be shown and not removed because of facet limit.setFilterDependencies
(String... filterDependencies) Set one or more URL-style filters of other facets that are required to make this facet visible.setFilterSensitive
(boolean isFilterSensitive) Set to true if the attributes for a facet can have multiple values per document, but the facet should only return the filtered one.setIsFilterSensitive
(boolean isFilterSensitive) setIsMultiSelect
(boolean isMultiSelect) Label of that facetsetMetaData
(Map<String, Object> metaData) Optional map that is returned with that facet.setMinFacetCoverage
(double minFacetCoverage) Set the minimum ratio of the result a facet has to cover in order to be displayed.setMinValueCount
(int minValueCount) Set the minimum amount of values a facet must have in order to be displayed.setMultiSelect
(boolean isMultiSelect) Set to true if it should be possible to select several different values of the same facet.setOptimalValueCount
(int optimalValueCount) Primary used for numeric facets to build according number of value ranges / intervals.setOrder
(int order) Optional index, to put the facets in a consistent order.setPreferVariantOnFilter
(boolean preferVariantOnFilter) Set to true, if variant documents should be preferred in the result in case a filter of that facet/field is used.setRemoveOnSingleFullCoverageFacetElement
(boolean enable) If set to true, that facet is removed in case it has a single element that covers all result products.setShowUnselectedOptions
(boolean showUnselectedOptions) Set to true if all options should be shown after filtering on one of the options of the same facet.setSourceField
(String sourceField) Required: Set name of data field that is configured with these config.Optional type that relates to the available FacetCreators.Set the order of the facet values.
-
Constructor Details
-
FacetConfig
public FacetConfig()
-
-
Method Details
-
setLabel
Label of that facet- Parameters:
label
- label to set- Returns:
- self
-
setSourceField
Required: Set name of data field that is configured with these config.- Parameters:
sourceField
- set field name this facet relates to- Returns:
- self
-
setType
Optional type that relates to the available FacetCreators. If not set, it uses the default type of the related field.
From some field-types different facet types can be generated:- numeric fields generate "interval" facets per default, but can be set to "range"
- TODO: custom facet creators can support their own facet types
If set to 'ignore' the facet creation is avoided, even if that facet is indexed.
- Parameters:
type
- type of facet- Returns:
- self
-
setMetaData
Optional map that is returned with that facet. Can be used for additional data you need with the facet for visualizing.- Parameters:
metaData
- arbitrary data map- Returns:
- self
-
setOptimalValueCount
Primary used for numeric facets to build according number of value ranges / intervals. This value is then used to determine how many intervals are created.
For Term Facets if set set to a value greater than 1, it leads to facets being removed in case they have a single entry with a facet-coverage of 100%.
- Parameters:
optimalValueCount
- this is a number- Returns:
- self
-
setShowUnselectedOptions
Set to true if all options should be shown after filtering on one of the options of the same facet.- Parameters:
showUnselectedOptions
- set true to activate- Returns:
- self
-
setMultiSelect
Set to true if it should be possible to select several different values of the same facet.- Parameters:
isMultiSelect
- set true to activate- Returns:
- self
-
setIsMultiSelect
-
setFilterSensitive
Set to true if the attributes for a facet can have multiple values per document, but the facet should only return the filtered one.- Parameters:
isFilterSensitive
-- Returns:
-
setIsFilterSensitive
-
setOrder
Optional index, to put the facets in a consistent order.- Parameters:
order
- numeric value between 0 and 127- Returns:
- self
-
setExcludeFromFacetLimit
If set to true, this facet will always be shown and not removed because of facet limit.- Parameters:
excludeFromFacetLimit
- set true to activate- Returns:
- self
-
setPreferVariantOnFilter
Set to true, if variant documents should be preferred in the result in case a filter of that facet/field is used. This can only be used for facets/fields, that exist on variant level, otherwise it is ignored.
If several facets have this flag activated, one of them must be filtered to prefer a variant. E.g. if you have different variants per "color" and "material", and you set this flag for both facets, variants will be shown if there is either a color or a material filter.
- Parameters:
preferVariantOnFilter
- default is false. set to true to activate.- Returns:
- self
-
setValueOrder
public FacetConfiguration.FacetConfig setValueOrder(FacetConfiguration.FacetConfig.ValueOrder valueOrder) Set the order of the facet values. Defaults to COUNT which means, the value with the highest result coverage will be listed first.
This setting is only used for term-facets and category-facets.
- Parameters:
valueOrder
- order of the values for that facet- Returns:
- self
-
setMinFacetCoverage
Set the minimum ratio of the result a facet has to cover in order to be displayed.
For example with a value of 0.2 for a "color" facet, it will only be shown, if at least 20% of the products in a result have a "color" attribute (even if all have the same color).
Per default that value is set to 0.1.
- Parameters:
minFacetCoverage
- value between 0 and 1, defining the ratio of a facet's result coverate.- Returns:
- self
-
setMinValueCount
Set the minimum amount of values a facet must have in order to be displayed.
For example with a value of 2 for a "color" facet, that facet will only be shown, if the result contains matches with at least 2 different colors, e.g. "black" and "red".
Per default the value is 2.
For facets with a total value count lower than this setting, this setting is automatically reduced to exactly that determined total value count.
- Parameters:
minValueCount
- value equals or greater than 0- Returns:
- self
-
setFilterDependencies
Set one or more URL-style filters of other facets that are required to make this facet visible. This can also refer to custom parameters that don't match an existing field/filter.
The facet with such dependencies will only be displayed if one of those filters is present. A filter-definition can also contain more than one filter dependency.
If a facet should just generally depend on a filter, a wildcard can be used to denote that, for example "category=*" as dependency would make a facet be displayed as soon as any category filter is selected.
(However the wildcard is not some kind of regular expression, so it can NOT be used to express some partial matching! For example "category=F*" would be considered as dependency on exactly that filter value.)More examples:
- Multiple filter dependencies:
filterDependencies: [ "category=furniture", "category=apparel" ]
With this setting, a facet is only shown, if the category "furniture" OR "apparel" is selected.
- Combined filter dependency:
filterDependencies: [ "category=furniture&brand=mybrand" ]
With this setting, a facet is only shown, if the category "furniture" AND the brand "mybrand" are selected.
- Multivalue filter dependency:
filterDependencies: [ "color=red,black" ]
With this setting, a facet is only shown, if the colors "red" AND "black" are selected. More selected colors would not have an impact.
- Dependency on path filter:
filterDependencies: [ "category=furniture/closets" ]
With this setting, the size facet is only shown, if the full category path "furniture/closets" is selected.
Please note that if those categories are filtered by their ID, this dependency won't match. In such a case the IDs must be defined here.
It is only possible to defined filter parameters, not "limit", "offset", "q" or any other reserved parameter. Those will make a facet disappear completely because such filter will never be set.
Also keep in mind, that the filters from this setting are parsed as URL query parameters, so values like '%25' are decoded accordingly. It is not required to encode everything, however it is necessary for reserved characters [
/,=&%
] that appear inside values.- Parameters:
filterDependencies
- list of filter dependencies- Returns:
- self
- Multiple filter dependencies:
-
setRemoveOnSingleFullCoverageFacetElement
If set to true, that facet is removed in case it has a single element that covers all result products.
Does not apply to numeric interval and range facets.
- Parameters:
enable
-- Returns:
-
isMandatoryFacet
public boolean isMandatoryFacet()
-