SCORE

Use the SCORE operator in SELECT statements to return the score values produced by CONTAINS and JSON_TEXTCONTAINS queries.

The SCORE operator can be used in a SELECT, ORDER BY, or GROUP BY clause.

The SCORE operator also supports database links. You can identify a remote table or materialized view by appending @dblink to the end of its name. The dblink must be a complete or partial name for a database link to the database containing the remote table or materialized view. (Querying of remote views is not supported.)

Syntax

SCORE(label NUMBER)

Here, label specifies a number to identify the score produced by the query. Use this number to identify the CONTAINS clause that returns this score.

Notes

For nested queries, you must specify an alias to avoid errors. For example, here an alias “s” is used in the inner SELECT query to identify the outer SELECT query:

SELECT s FROM (
      SELECT SCORE(1) AS s FROM mytable
      WHERE CONTAINS(text, 'oracle', 1) > 0
);

Examples

SELECT SCORE(1), title from newsindex
      WHERE CONTAINS(text, 'oracle', 1) > 0

      ORDER BY SCORE(1) DESC;
SELECT title, body, SCORE(10), SCORE(20)
      FROM news
      WHERE CONTAINS (news.title, 'Oracle', 10) > 0 OR

      CONTAINS (news.body, 'java', 20) > 0

      ORDER BY SCORE(10), SCORE(20);

Related Topics