Previous   Next 

Tsearch2 README File Example: Overview (Continued)

Toggle the display to print columns vertically and instead of horizontally.

\x    

Perform a search for the words 'database' or 'query'. Limit the results to the 5 highest ranking results.

SELECT *, headline(line, to_tsquery('database | query')), rank(ts_vec, to_tsquery('database | query'))
FROM ts_readme
WHERE ts_vec @@ to_tsquery('database | query')
ORDER BY rank(ts_vec, to_tsquery('database | query')) DESC
LIMIT 3;

-[ RECORD 1 ]--------------------------------------------------------------------------------------------
line_number | 44
line        |     (documents could be stored in file system), database and query engine.
ts_vec      | 'file':6 'could':2 'engin':11 'queri':10 'store':4 'system':7 'databas':8 'document':1
headline    |     (documents could be stored in file system), database and query engine.
rank        | 0.19
-[ RECORD 2 ]--------------------------------------------------------------------------------------------
line_number | 38
line        |     tsearch2 as a storage, while database engine is used as a query executor
ts_vec      | 'use':9 'engin':7 'queri':12 'storag':4 'databas':6 'executor':13 'tsearch2':1
headline    |     tsearch2 as a storage, while database engine is used as a query executor
rank        | 0.19
-[ RECORD 3 ]--------------------------------------------------------------------------------------------
line_number | 20
line        |    GiST), which provides online update of full text index and fast query
ts_vec      | 'fast':11 'full':7 'gist':1 'text':8 'index':9 'onlin':4 'queri':12 'updat':5 'provid':3
headline    |    GiST), which provides online update of full text index and fast query
rank        | 0.1