Example that uses the CONTAINS function and SCORE function

You can use the CONTAINS function and the SCORE function in the same query to search a text search index.

The result of a query that uses the CONTAINS function and the SCORE function returns whether a match was found and a relevance score that measures how well a document matches the query.

The example in the following table uses data from the base table BOOKS with the columns ISBN (VARCHAR(20)), ABSTRACT (VARCHAR(10000)), PRICE (INTEGER), and BOOKRID (ROWID NOT NULL).
Table 1. The base table BOOKS
ISBN ABSTRACT PRICE BOOKRID
i1 "a b c" 7 ROWID NOT NULL
i2 "a b d" 10 ROWID NOT NULL
i3 "a e a" 8 ROWID NOT NULL
You run the following query:
SELECT ISBN, SCORE(ABSTRACT,'"a"')
FROM BOOKS
WHERE CONTAINS (ABSTRACT,'"a"') = 1
This query returns the following results:
i1,	0.300000000000000E-02
i2,	0.300000000000000E-02
i3,	0.900000000000000E-02

The score values might differ depending on the content of the text column.