DEFINESCORE

Use the DEFINESCORE operator to define how a term or phrase, or a set of term equivalences will be scored. The definition of a scoring expression can consist of an arithmetic expression of predefined scoring components and numeric literals. DEFINEMERGE can be used after DEFINESCORE.

Syntax

DEFINESCORE (query_term, scoring_expression)

query_term

The query term or phrase. Expressions containing the following operators are also allowed:

Operators Operators
ABOUT EQUIV(=)
Fuzzy Soundex (!)
Stem ($) Wildcards (% _)
SDATA MDATA

scoring_expression

An arithmetic expression that describes how the query_term should be scored. This operand is a string that contains the following components:

scoring_expression Syntax

<Exp>   :=         <Exp> + <Term> | <Exp> - <Term> |  <Term>

<Term>   :=         <Term> * <Factor> | <Term> / <Factor> | <Factor>

<Factor> :=         <<NumericLiterals >>| DISCRETE | OCCURRENCE | RELEVANCE |
         COMPLETION | IGNORE |  ( <Exp> ) | -<Factor> | Abs(<Exp>) | Log(<Exp>)

Examples for DEFINESCORE Operator

'DEFINESCORE (dog, OCCURRENCE)'

Queries for the word dog, and scores each document using the occurrence score. Returns the score as integer.

'DEFINESCORE (Labradors are big dog, RELEVANCE)'

Queries for the phrase Labradors are big dogs, and scores each document using the relevance score.

'cat and DEFINESCORE (dog, IGNORE)'

Queries for the words dog and cat, using only the default relevance score of cat as the overall score of the document. Returns the score as integer.

'DEFINESCORE (dog, IGNORE)'

Queries for the word dog, and returns all documents with the word dog. The result is the same as if all documents get a score of 100. Returns the score as integer.

'DEFINESCORE (dog, ABS (100-RELEVANCE))'

Queries for the word dog, and scores each document using the absolute value of 100 minus the relevance score. Returns the score as integer.

'cat and DEFINESCORE (dog, RELEVANCE*5 - OCCURRENCE)'

Returns a syntax error: Two predefined components are used.

When DEFINESCORE is used with query templates, the scoring_expression overrides the values specified by the template. The following example queries for “dog” and “cat,” scores “cat” using OCCURRENCE(COUNT) and scores “dog” based on RELEVANCE.

<query>
      <textquery grammar="CONTEXT" lang="english">
                 DEFINESCORE(dog, RELEVANCE) and  cat
      </textquery>
      <score datatype="INTEGER" algorithm="COUNT"/>
</query>

Limitations

'DEFINESCORE (dog, COMPLETION) within zonesection'

otherwise, the query will return a syntax error.

See Also: Oracle Database SQL Language Reference

Notes

DEFINESCORE('dog', OCCURRENCE) AND DEFINESCORE('cat', RELEVANCE)

Queries for the term “dog” using occurrence scoring, and the term “cat” using relevance scoring.

SYN(DEFINESCORE('cat', OCCURRENCE))
<query>
    <textquery grammar="CONTEXT" lang="english">
        DEFINESCORE(dog, RELEVANCE) and  cat
    </textquery>
    <score datatype="INTEGER" algorithm="COUNT"/>
</query>

Queries for “dog” and “cat”, scores “cat” using OCCURRENCE(COUNT), and scores “dog” based on RELEVANCE.

DEFINEMERGE.