How do I handle the following PostgreSQL function in Web2py?

ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector;
UPDATE pgweb SET textsearchable_index_col =
     to_tsvector('english', coalesce(title,'') || ' ' || coalesce(body,''));

I know I can use executesql for creating the indexes but in some cases
it is preferable to create a column with the type 'tsvector' as in the
example above or in the one below:

CREATE TABLE messages (
    title       text,
    body        text,
    tsv         tsvector
);

And then how do I handle queries like this?

SELECT title, body FROM messages WHERE tsv @@ to_tsquery('title & body');


Regards
Johann



-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
                                                    2 Pet. 1:2b,3a

Reply via email to