Re: Tsearch2 trigger firing...

From: "Net Virtual Mailing Lists" <mailinglists(at)net-virtual(dot)com>
To: "Pgsql General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Tsearch2 trigger firing...
Date: 2004-10-17 04:07:40
Message-ID: 20041017040740.8909@mail.e-na.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

Thank you to Oleg for your help with this earlier! It resolved it very
nicely!

I still have one remaining issue which I can't figure out, perhaps best
explained with an example:

CREATE TABLE sometable (
title TEXT,
body TEXT,
footer TEXT,
all_fti TSVECTOR
);

UPDATE sometable SET all_fti = setweight(to_tsvector(title), 'A') ||
setweight(to_tsvector(body),'B') || setweight(to_tsvector(footer), 'C');

INSERT INTO sometable (title, body, footer) VALUES ('something in the
title', 'something in the body', 'something in the footer');
INSERT INTO sometable (title, body, footer) VALUES ('anything in the
title', 'anything in the body', 'anything in the footer');
INSERT INTO sometable (title, body, footer) VALUES ('whatever in the
title', 'whatever in the body', 'whatever in the footer');

.. What I can't figure out is how to make those last 3 inserts
automatically update all_fti via a trigger... The documentation would
show something like:

CREATE TRIGGER sometable_update_fti BEFORE UPDATE OR INSERT ON sometable
FOR EACH ROW EXECUTE PROCEDURE tsearch2(all_fti, title, body, footer);

.. but as expected, this does not take into account the result of the
"setweight" function.... Unfortunately, I am not very skilled with
Postgres's triggers (yet) and I can't find any documentation on how to go
about this...

Any thoughts?.....

- Greg

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ken Tozier 2004-10-17 04:25:07 Re: Newbie table definition question
Previous Message Scott Marlowe 2004-10-17 04:05:11 Re: dealing with invalid date