Example: Using the CONTAINS function and SCORE function
You can use the CONTAINS function or the SCORE function in the same query to search a text search index and to return if and how frequently the text document matches the search argument criteria.
The example in the following table uses data from the base table
BOOKS with the columns ISBN (VARCHAR(20)), ABSTRACT (VARCHAR(10000)), and
PRICE (INTEGER).
ISBN | ABSTRACT | PRICE |
---|---|---|
i1 | "a b c" | 7 |
i2 | "a b d" | 10 |
i3 | "a e a" | 8 |
You run the following query:
SELECT ISBN, SCORE(ABSTRACT,'"b"')
FROM BOOKS
WHERE CONTAINS (ABSTRACT,'"b"') = 1
This query returns the following
two rows:i1, 0.3
i3, 0.4
The score values might differ depending on the content of the text column.