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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
Defines the ending time for which this relevancy rule is active.Defines the beginning time for which this relevancy rule is active.Miscellaneous attributes for this relevancy rule.getBoost()
The amount to boost documents that match this relevancy rule.The rule required to be met for this relevancy rule to be active.com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
A subset ofTracking
information to expose the context state for this object.getField()
TheFieldRef
this relevancy rule belongs to.getId()
The context ID of the relevancy rule.The text to match against when using aDefaultRelevancyRuleTypes.MATCHING_VALUE
rule type.This field can be set to provide the lower limit for a boost function score.getName()
The friendly name to identify this relevancy rule.The type of rule that is setup to apply relevancy boosts.The search term required to match for this relevancy rule to be active.The field variant type that should be boosted for this rule.int
hashCode()
boolean
boolean
Whether or not to apply a small boost for a higher frequency of matching values within the field.boolean
Whether or not the relevancy rule boosts results by the highest or lowest value.boolean
boolean
Whether or not to evaluate the match against thegetSearchTermMatch()
with regex enabled.void
setActiveEndDate
(Instant activeEndDate) Defines the ending time for which this relevancy rule is active.void
setActiveStartDate
(Instant activeStartDate) Defines the beginning time for which this relevancy rule is active.void
setApplyMatchingValueFrequencyBoost
(boolean applyMatchingValueFrequencyBoost) Whether or not to apply a small boost for a higher frequency of matching values within the field.void
setAttributes
(Map<String, Object> attributes) Miscellaneous attributes for this relevancy rule.void
The amount to boost documents that match this relevancy rule.void
setBoostRule
(String boostRule) The rule required to be met for this relevancy rule to be active.void
setContextState
(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.void
setDescending
(boolean descending) Whether or not the relevancy rule boosts results by the highest or lowest value.void
TheFieldRef
this relevancy rule belongs to.void
The context ID of the relevancy rule.void
setMatchingValue
(String matchingValue) The text to match against when using aDefaultRelevancyRuleTypes.MATCHING_VALUE
rule type.void
setMinimumScore
(Double minimumScore) This field can be set to provide the lower limit for a boost function score.void
The friendly name to identify this relevancy rule.void
setRuleType
(String ruleType) The type of rule that is setup to apply relevancy boosts.void
setSearchTermMatch
(String searchTermMatch) The search term required to match for this relevancy rule to be active.void
setSearchTermRegex
(boolean searchTermRegex) Whether or not to evaluate the match against thegetSearchTermMatch()
with regex enabled.void
setVariantType
(String variantType) The field variant type that should be boosted for this rule.toString()
-
Constructor Details
-
RelevancyRule
public RelevancyRule()
-
-
Method Details
-
isRuledRelevancyRule
public boolean isRuledRelevancyRule() -
hasSearchTermMatch
public boolean hasSearchTermMatch() -
getFieldDefinitionId
-
getFieldIndexableType
-
getId
The context ID of the relevancy rule.- Returns:
- the context ID of the relevancy rule
-
getField
TheFieldRef
this relevancy rule belongs to. Onlyid
,indexableType
, andlabel
are serialized in API responses.- Returns:
- field to be sorted on
-
getName
The friendly name to identify this relevancy rule.- Returns:
- friendly name to identify this relevancy rule
-
getVariantType
The field variant type that should be boosted for this rule.- Returns:
- the variant type that should be boosted for this rule
-
getActiveStartDate
Defines the beginning time for which this relevancy rule is active. If both the active start date and theactive 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
Defines the ending time for which this relevancy rule is active. If theactive 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
The type of rule that is setup to apply relevancy boosts. SeeDefaultRelevancyRuleTypes
for all available types.- Returns:
- the type of rule that is setup to apply relevancy boosts
-
getBoost
The amount to boost documents that match this relevancy rule.- Returns:
- the amount to boost documents that match this relevancy rule
-
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
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
The text to match against when using aDefaultRelevancyRuleTypes.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 thegetSearchTermMatch()
with regex enabled.- Returns:
- whether or not to evaluate the match against the
getSearchTermMatch()
with regex enabled
-
getSearchTermMatch
The search term required to match for this relevancy rule to be active. IfisSearchTermRegex()
istrue
, 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
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 ofTracking
information to expose the context state for this object.- Specified by:
getContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Returns:
- a subset of
Tracking
information to expose the context state for this object
-
setId
The context ID of the relevancy rule.- Parameters:
id
- the context ID of the relevancy rule
-
setField
TheFieldRef
this relevancy rule belongs to. Onlyid
,indexableType
, andlabel
are serialized in API responses.- Parameters:
field
- field to be sorted on
-
setName
The friendly name to identify this relevancy rule.- Parameters:
name
- friendly to identify this relevancy rule
-
setVariantType
The field variant type that should be boosted for this rule.- Parameters:
variantType
- the variant type that should be boosted for this rule
-
setActiveStartDate
Defines the beginning time for which this relevancy rule is active. If both the active start date and theactive 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
Defines the ending time for which this relevancy rule is active. If theactive 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
The type of rule that is setup to apply relevancy boosts. SeeDefaultRelevancyRuleTypes
for all available types.- Parameters:
ruleType
- the type of rule that is setup to apply relevancy boosts
-
setBoost
The amount to boost documents that match this relevancy rule.- Parameters:
boost
- the amount to boost documents that match this relevancy rule
-
setBoostRule
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
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
The text to match against when using aDefaultRelevancyRuleTypes.MATCHING_VALUE
rule type. Boosts any documents whose field contains this value.- Parameters:
matchingValue
- the text to match against when using aDefaultRelevancyRuleTypes.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 thegetSearchTermMatch()
with regex enabled.- Parameters:
searchTermRegex
- whether or not to evaluate the match against thegetSearchTermMatch()
with regex enabled
-
setSearchTermMatch
The search term required to match for this relevancy rule to be active. IfisSearchTermRegex()
istrue
, 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
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 ofTracking
information to expose the context state for this object.- Specified by:
setContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Parameters:
contextState
- a subset ofTracking
information to expose the context state for this object
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-