dbTalk Databases Forums  

Re: Tsearch2 trigger firing...

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Re: Tsearch2 trigger firing... in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Net Virtual Mailing Lists
 
Posts: n/a

Default Re: Tsearch2 trigger firing... - 10-16-2004 , 11:07 PM






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


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #2  
Old   
Oleg Bartunov
 
Posts: n/a

Default Re: Tsearch2 trigger firing... - 10-17-2004 , 12:55 AM






On Sat, 16 Oct 2004, Net Virtual Mailing Lists wrote:

Quote:
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?.....

You're right, tsearch2 trigger doesn't supports tsvector as argument yet.
The problem is in rather complex argument recognition. I don't know
any workaround, so take a look on sources or wait until we'll have spare
time to implement it.


Quote:
- Greg


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Regards,
Oleg
__________________________________________________ ___________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg (AT) sai (DOT) msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.