Alternative and User-Defined Scoring
You can use query templating to specify alternative scoring algorithms. Those algorithms help you customize how CONTAINS is scored. They also enable SDATA to be used as part of the scoring expressions. In this way, you can mathematically define the scoring expression by using not only predefined scoring components, but also SDATA components.
With alternative user-defined scoring, you can specify:
-
Scoring expressions of terms by defining arithmetic expressions that define how the query should be scored, using
-
predefined scoring algorithms:
DISCRETE,OCCURRENCE,RELEVANCE, andCOMPLETION -
arithmetic operations: plus, minus, multiply, divide
-
arithmetic functions:
ABS(n), finding the absolute value of n ;LOG(n), finding the base-10 logarithmic value of n -
Numeric literals
-
-
Scoring expressions at the term level
-
Terms that should not be taken into account when calculating the score
-
How the score from child elements of
ORandANDoperators should be merged -
Use
You can also use the SDATA that stores numeric or DATETIME values to affect the final score of the document.
The following example specifies an alternative scoring algorithm:
select id from docs where CONTAINS (text,
'<query>
<textquery grammar="CONTEXT" lang="english"> mustang </textquery>
<score datatype="float" algorithm="DEFAULT"/>
</query>')>0
The following query templating example includes SDATA values as part of the final score:
select id from docs where CONTAINS (text,
'<query>
<textquery grammar="CONTEXT" lang="english"> mustang </textquery>
<score datatype="float" algorithm="DEFAULT" normalization_expr ="doc_score+SDATA(price)"/>
</query>')>0"
See Also: “Using DEFINESCORE and DEFINEMERGE for User-defined Scoring”