Class RelevancyRule

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

public class RelevancyRule extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
This represents a rule that can be configured to increase the relevancy of a document. This can be applied to any document field that is searchable.
Since:
Search Service 2.2.0, Release Train 2.2.0
See Also:
  • Constructor Details

    • RelevancyRule

      public RelevancyRule()
  • Method Details

    • isRuledRelevancyRule

      public boolean isRuledRelevancyRule()
    • hasSearchTermMatch

      public boolean hasSearchTermMatch()
    • getFieldDefinitionId

      public String getFieldDefinitionId()
    • getFieldIndexableType

      public String getFieldIndexableType()
    • getId

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

      public FieldRef getField()
      The FieldRef this relevancy rule belongs to. Only id, indexableType, and label are serialized in API responses.
      Returns:
      field to be sorted on
    • getName

      public String getName()
      The friendly name to identify this relevancy rule.
      Returns:
      friendly name to identify this relevancy rule
    • getVariantType

      public String getVariantType()
      The field variant type that should be boosted for this rule.
      Returns:
      the variant type that should be boosted for this rule
    • getActiveStartDate

      @Nullable public Instant getActiveStartDate()
      Defines the beginning time for which this relevancy rule is active. If both the active start date and the active end date are null, this relevancy rule is considered to always be active.
      Returns:
      the beginning time for which this relevancy rule is active
      See Also:
    • getActiveEndDate

      @Nullable public Instant getActiveEndDate()
      Defines the ending time for which this relevancy rule is active. If the active start date is not null, but the active end date is, the relevancy rule is considered to be active forever, starting on the start date.
      Returns:
      the ending time for which this relevancy rule is active
      See Also:
    • getRuleType

      public String getRuleType()
      The type of rule that is setup to apply relevancy boosts. See DefaultRelevancyRuleTypes for all available types.
      Returns:
      the type of rule that is setup to apply relevancy boosts
    • getBoost

      public Double getBoost()
      The amount to boost documents that match this relevancy rule.
      Returns:
      the amount to boost documents that match this relevancy rule
    • getBoostRule

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

      public Double getMinimumScore()
      This field can be set to provide the lower limit for a boost function score. Only used for ordinal & relative rule types.
      Returns:
      provides the lower limit for a boost function score
    • isDescending

      public boolean isDescending()
      Whether or not the relevancy rule boosts results by the highest or lowest value. This field is only used for ordinal & relative rule types. By default, assumption is an descending sort.
      Returns:
      whether or not the relevancy rule boosts results by the highest or lowest value
    • getMatchingValue

      public String getMatchingValue()
      The text to match against when using a DefaultRelevancyRuleTypes.MATCHING_VALUE rule type. Boosts any documents whose field contains this value.
      Returns:
      the text to match against when using a DefaultRelevancyRuleTypes.MATCHING_VALUE rule type
    • isApplyMatchingValueFrequencyBoost

      public boolean isApplyMatchingValueFrequencyBoost()
      Whether or not to apply a small boost for a higher frequency of matching values within the field.
      Returns:
      whether or not to apply a small boost for a higher frequency of matching values within the field
    • isSearchTermRegex

      public boolean isSearchTermRegex()
      Whether or not to evaluate the match against the getSearchTermMatch() with regex enabled.
      Returns:
      whether or not to evaluate the match against the getSearchTermMatch() with regex enabled
    • getSearchTermMatch

      public String getSearchTermMatch()
      The search term required to match for this relevancy rule to be active. If isSearchTermRegex() is true, then this search term will be evaluated as a regex expression. If left empty, will assume that every search term matches.
      Returns:
      the search term required to match for this relevancy rule to be active
    • getAttributes

      public Map<String,Object> getAttributes()
      Miscellaneous attributes for this relevancy rule.
      Returns:
      Miscellaneous attributes for this relevancy rule.
    • 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 relevancy rule.
      Parameters:
      id - the context ID of the relevancy rule
    • setField

      public void setField(FieldRef field)
      The FieldRef this relevancy rule belongs to. Only id, indexableType, and label are serialized in API responses.
      Parameters:
      field - field to be sorted on
    • setName

      public void setName(String name)
      The friendly name to identify this relevancy rule.
      Parameters:
      name - friendly to identify this relevancy rule
    • setVariantType

      public void setVariantType(String variantType)
      The field variant type that should be boosted for this rule.
      Parameters:
      variantType - the variant type that should be boosted for this rule
    • setActiveStartDate

      public void setActiveStartDate(@Nullable Instant activeStartDate)
      Defines the beginning time for which this relevancy rule is active. If both the active start date and the active end date are null, this relevancy rule is considered to always be active.
      Parameters:
      activeStartDate - the beginning time for which this relevancy rule is active
      See Also:
    • setActiveEndDate

      public void setActiveEndDate(@Nullable Instant activeEndDate)
      Defines the ending time for which this relevancy rule is active. If the active start date is not null, but the active end date is, the relevancy rule is considered to be active forever, starting on the start date.
      Parameters:
      activeEndDate - the ending time for which this relevancy rule is active
      See Also:
    • setRuleType

      public void setRuleType(String ruleType)
      The type of rule that is setup to apply relevancy boosts. See DefaultRelevancyRuleTypes for all available types.
      Parameters:
      ruleType - the type of rule that is setup to apply relevancy boosts
    • setBoost

      public void setBoost(Double boost)
      The amount to boost documents that match this relevancy rule.
      Parameters:
      boost - the amount to boost documents that match this relevancy rule
    • setBoostRule

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

      public void setMinimumScore(Double minimumScore)
      This field can be set to provide the lower limit for a boost function score. Only used for ordinal & relative rule types.
      Parameters:
      minimumScore - provides the lower limit for a boost function score
    • setDescending

      public void setDescending(boolean descending)
      Whether or not the relevancy rule boosts results by the highest or lowest value. This field is only used for ordinal & relative rule types. By default, assumption is an descending sort.
      Parameters:
      descending - whether or not the relevancy rule boosts results by the highest or lowest value
    • setMatchingValue

      public void setMatchingValue(String matchingValue)
      The text to match against when using a DefaultRelevancyRuleTypes.MATCHING_VALUE rule type. Boosts any documents whose field contains this value.
      Parameters:
      matchingValue - the text to match against when using a DefaultRelevancyRuleTypes.MATCHING_VALUE rule type
    • setApplyMatchingValueFrequencyBoost

      public void setApplyMatchingValueFrequencyBoost(boolean applyMatchingValueFrequencyBoost)
      Whether or not to apply a small boost for a higher frequency of matching values within the field.
      Parameters:
      applyMatchingValueFrequencyBoost - whether or not to apply a small boost for a higher frequency of matching values within the field
    • setSearchTermRegex

      public void setSearchTermRegex(boolean searchTermRegex)
      Whether or not to evaluate the match against the getSearchTermMatch() with regex enabled.
      Parameters:
      searchTermRegex - whether or not to evaluate the match against the getSearchTermMatch() with regex enabled
    • setSearchTermMatch

      public void setSearchTermMatch(String searchTermMatch)
      The search term required to match for this relevancy rule to be active. If isSearchTermRegex() is true, then this search term will be evaluated as a regex expression. If left empty, will assume that every search term matches.
      Parameters:
      searchTermMatch - the search term required to match for this relevancy rule to be active
    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Miscellaneous attributes for this relevancy rule.
      Parameters:
      attributes - Miscellaneous attributes for this relevancy rule.
    • 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