Searching and returning the score of a found text document

SCORE is an absolute value that indicates how well the document meets the search value relative to other found documents. The value indicates the number of matches that are found in the document in relation to the document's size. In the following example, you can get the score of a found document by using the SCORE function:

WITH TEMPTABLE(docid,score)
        AS (SELECT docid,
                   SCORE(COMMENT,'"book"')
        FROM DB2EXT.TEXTTAB)
SELECT *
        FROM TEMPTABLE
        WHERE score > 0  
        ORDER BY score ASC

SCORE returns a DOUBLE value between 0 and 1.

Note

You cannot use the CONTAINS, SCORE, and NUMBEROFMATCHES search functions for indexes created on views.

In a distributed DB2 environment, the SCORE values are different: