Class FacetConfiguration.FacetConfig

java.lang.Object
de.cxp.ocs.config.FacetConfiguration.FacetConfig
Enclosing class:
FacetConfiguration

public static class FacetConfiguration.FacetConfig extends Object
  • Constructor Details

    • FacetConfig

      public FacetConfig()
  • Method Details

    • setLabel

      public FacetConfiguration.FacetConfig setLabel(String label)
      Label of that facet
      Parameters:
      label - label to set
      Returns:
      self
    • setSourceField

      public FacetConfiguration.FacetConfig setSourceField(String sourceField)
      Required: Set name of data field that is configured with these config.
      Parameters:
      sourceField - set field name this facet relates to
      Returns:
      self
    • setType

      public FacetConfiguration.FacetConfig setType(String type)

      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

      public FacetConfiguration.FacetConfig setMetaData(Map<String,Object> metaData)
      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

      public FacetConfiguration.FacetConfig setOptimalValueCount(int optimalValueCount)

      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

      public FacetConfiguration.FacetConfig setShowUnselectedOptions(boolean showUnselectedOptions)
      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

      public FacetConfiguration.FacetConfig setMultiSelect(boolean isMultiSelect)
      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

      public FacetConfiguration.FacetConfig setIsMultiSelect(boolean isMultiSelect)
    • setFilterSensitive

      public FacetConfiguration.FacetConfig 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.
      Parameters:
      isFilterSensitive -
      Returns:
    • setIsFilterSensitive

      public FacetConfiguration.FacetConfig setIsFilterSensitive(boolean isFilterSensitive)
    • setOrder

      public FacetConfiguration.FacetConfig setOrder(int order)
      Optional index, to put the facets in a consistent order.
      Parameters:
      order - numeric value between 0 and 127
      Returns:
      self
    • setExcludeFromFacetLimit

      public FacetConfiguration.FacetConfig setExcludeFromFacetLimit(boolean excludeFromFacetLimit)
      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

      public FacetConfiguration.FacetConfig 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. 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

      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

      public FacetConfiguration.FacetConfig setMinFacetCoverage(double minFacetCoverage)

      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

      public FacetConfiguration.FacetConfig setMinValueCount(int minValueCount)

      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

      public FacetConfiguration.FacetConfig setFilterDependencies(String... filterDependencies)

      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
    • setRemoveOnSingleFullCoverageFacetElement

      public FacetConfiguration.FacetConfig setRemoveOnSingleFullCoverageFacetElement(boolean enable)

      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()