java.lang.Object
com.broadleafcommerce.search.api.domain.Facet
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class Facet extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
This represents an available search facet and its filtering options. This can represent any property that is filterable. For example, this could represent an item like Color, Manufacturer, Price, etc.

Since 2.1.0-GA, Facets are managed as independent entities from FieldDefinitions rather than being embedded.

See Also:
  • Constructor Details

    • Facet

      public Facet()
  • Method Details

    • isRuledFacet

      public boolean isRuledFacet()
    • getFieldDefinitionId

      public String getFieldDefinitionId()
    • getFieldIndexableType

      public String getFieldIndexableType()
    • getId

      public String getId()
      The context ID of the facet.
      Returns:
      the context ID of the facet
    • getField

      public FieldRef getField()
      The FieldRef this facet belongs to. This is null if not using SearchSettings. Only id, indexableType, and label are serialized in API responses.
      Returns:
      field to be sorted on
    • getLabel

      public String getLabel()
      A value intended for display on a UI. For example, "Manufacturer", "Price", "Category", etc.
      Returns:
      displayable label for this facet
    • getName

      public String getName()
      Name to use to identify the facet. Typically, this should correspond to a FieldDefinition.getAbbreviation().
      Returns:
      Name to use to identify the facet.
    • getVariantType

      public String getVariantType()
      The field variant type which should be faceted on.
      Returns:
      the variant type which should be faceted on
    • getDisplayOrder

      public Integer getDisplayOrder()
      Order in which to display this facet on a list of facets. A lower number indicates this item will occur earlier in the returned facet list.
      Returns:
      order in which this facet should appear in a list
    • isMultiSelect

      public boolean isMultiSelect()
      Determines whether or not this facet allows multiple values to be selected.
      Returns:
      can multiple options of this facet be selected?
    • isRanged

      public boolean isRanged()
      Designates whether or not this facet is ranged. For example price might be a ranged facet ($0.00-49.99, $50.00-99.99, etc), or date ranges.
      Returns:
      is this a ranged facet?
    • getRanges

      public List<FacetRange> getRanges()
      The different range options available for filtering on this search facet.
      Returns:
      available range options for this facet
    • getFacetRule

      public String getFacetRule()
      The rule required to be met for this facet to be active. This is by default a SpEL expression, but may be any expression language.
      Returns:
      The facet rule.
      See Also:
    • getAttributes

      public Map<String,Object> getAttributes()
      Miscellaneous attributes for this facet.
      Returns:
      Miscellaneous attributes for this facet.
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • setId

      public void setId(String id)
      The context ID of the facet.
      Parameters:
      id - the context ID of the facet
    • setField

      public void setField(FieldRef field)
      The FieldRef this facet belongs to. This is null if not using SearchSettings. Only id, indexableType, and label are serialized in API responses.
      Parameters:
      field - field to be sorted on
    • setLabel

      public void setLabel(String label)
      A value intended for display on a UI. For example, "Manufacturer", "Price", "Category", etc.
      Parameters:
      label - displayable label for this facet
    • setName

      public void setName(String name)
      Name to use to identify the facet. Typically, this should correspond to a FieldDefinition.getAbbreviation().
      Parameters:
      name - Name to use to identify the facet.
    • setVariantType

      public void setVariantType(String variantType)
      The field variant type which should be faceted on.
      Parameters:
      facetVariantType - the variant type which should be faceted on
    • setDisplayOrder

      public void setDisplayOrder(Integer displayOrder)
      Order in which to display this facet on a list of facets. A lower number indicates this item will occur earlier in the returned facet list.
      Parameters:
      displayOrder - order in which this facet should appear in a list
    • setMultiSelect

      public void setMultiSelect(boolean multiSelect)
      Determines whether or not this facet allows multiple values to be selected.
      Parameters:
      multiSelect - can multiple options of this facet be selected?
    • setRanged

      public void setRanged(boolean ranged)
      Designates whether or not this facet is ranged. For example price might be a ranged facet ($0.00-49.99, $50.00-99.99, etc), or date ranges.
      Parameters:
      ranged - is this a ranged facet?
    • setRanges

      public void setRanges(List<FacetRange> ranges)
      The different range options available for filtering on this search facet.
      Parameters:
      ranges - available range options for this facet
    • setFacetRule

      public void setFacetRule(String facetRule)
      The rule required to be met for this facet to be active. This is by default a SpEL expression, but may be any expression language.
      Parameters:
      facetRule - The rule to evaluate.
      See Also:
    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Miscellaneous attributes for this facet.
      Parameters:
      attributes - Miscellaneous attributes for this facet.
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object