Tip
|
Since 2.2.0 |
Relevancy Rules are a query-time consideration for search, and provide a way to setup additional prioritization of documents based on a configured set of rules. The goal with relevancy rules is to allow fine-tuning of the results' order from a search request for specific queries. This can be tuned as little or as much as required by the business processes.
To support various prioritization strategies for search results, the following types were configured.
MATCHING_QUERY
This strategy boosts the documents whose field (as specified on the rule) matches the search term inputted by the user.
This applies a simple boost by query field; in Solr, this applies to the qf
params.
qf=some_field_s^2.0
MATCHING_VALUE
This strategy boosts the documents whose field and value (as specified on the rule) matches the search term inputted by the user.
This requires that a matching value
field is populated for the rule, e.g. Velvet Couch
.
Optionally, the rule can also consider the frequency of the value in the Solr document’s field if the matching value frequency boost is set to true
.
The conditions for the matching value rule are slightly more complex, as detailed below.
If the document’s field does not contain the matching value, return a boost equal to 1.0 (see footnote #1)
If the document’s field contains the matching value and the frequency boost is not enabled, returns the boost value
If the document’s field contains the matching value and the frequency boost is enabled, returns the log of the frequency plus one (see footnote #2) multiplied by the boost
The boosts are added to the Solr boost
parameter and all boosts that apply are multiplicative (see footnote #3).
ORDINAL
This strategy boost the documents based on ordinal lexographical ordering of the field (as specified on the rule). This rule type should be used for text-based variant types since it boosts based on the lexographical sort value of the field.
If the ordering is descending, then the lexographical order uses Solr’s reverse order function multiplied by the boost value. This would return values based on the
If the ordering is ascending (default), then the lexographical order uses Solr’s order function multiplied by the boost value.
In either case, if the calculated boost value is less than the minimum score specified on the rule, then the minimum score value is applied as the boost.
The boosts are added to the Solr boost
parameter and all boosts that apply are multiplicative (see footnote #3).
RELATIVE
This strategy boost the documents based on relative ordering of the field (as specified on the rule). This rule type should be used for Number or Money variant types since it boosts based on the numerical value of the field.
If the ordering is descending (default), then the order is the field value multiplied by the boost value.
If the ordering is ascending, then the order is the inverse of the field value plus one, 1/(value + 1). The addition of one is to prevent any division-by-zero mathematical errors.
In either case, if the calculated boost value is less than the minimum score specified on the rule, then the minimum score value is applied as the boost.
The boosts are added to the Solr boost
parameter and all boosts that apply are multiplicative (see footnote #3).
Returns a default boost of 1.0 since the boosts are multiplicative and returning a zero would remove any other boosts that applied. By returning 1, we’re using the identity property of multiplication which means the current boost of the document will remain unchanged.
Since Solr’s log function is base 10, if the frequency starts at 1, then the log(1) would equal zero. Since we’d want to start at 1, we add one to this result. With a frequency of 1, log(1) + 1 would equal 1 which would be multiplied by the boost. So the returned value would equal the boost value. However if the frequency was higher, let’s say 3, then log(3) + 1 would equal ~1.48 which would be multiplied by the boost value.
All boosts applied are multiplicative as recommended by Solr since it is more predictable than additive boosting with bf
and `bq params.
See the TIP callout in Solr’s bq subsection documentation.