The query is easy: db("@@ to_tsquery('%s');" % title_body.replace("'","''")).select()
to generate the table you need SQLCustomField and the compute attribute. Give it a try and please report back. I am very much interested in this issue. On Dec 1, 6:32 am, Johann Spies <johann.sp...@gmail.com> wrote: > 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