create table Docs
( id integer, title text, body text );
alter table Docs add column features tsvector;
update Docs set features =
to_tsvector('english', title||' '||body);
select title, ts_rank(d.features, query) as rank
from Docs d,
to_tsquery('potter|(roger&rabbit)') as query
where query @@ d.features
order by rank desc
limit 10;
|