]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - schemas/psql-tsearch2.sql
Slight pgsql harmonization
[SourceForge/phpwiki.git] / schemas / psql-tsearch2.sql
1 -- $Id: psql-tsearch2.sql,v 1.2 2007-01-28 23:35:59 rurban Exp $
2 -- Add the tsearch2 fulltextsearch extension to an existing phpwiki database. Recommended.
3 -- Tested with 7.4, 8.0, 8.1, 8.2
4
5 \set QUIET
6 \set prefix     ''
7 \set httpd_user 'wikiuser'
8
9 \echo 'You have to initialize the tsearch2 module first:'
10 \echo '  psql ' :prefix 'phpwiki < /usr/share/postgresql/contrib/tsearch2.sql'
11
12 \echo 'Did you customize the ispell and synonym dictionaries?'
13 -- remove the quit line below
14 \quit
15 --example of ISpell dictionary:
16 -- UPDATE pg_ts_dict SET dict_initoption='DictFile="/usr/local/share/ispell/russian.dict" ,AffFile ="/usr/local/share/ispell/russian.aff", StopFile="/usr/local/share/ispell/russian.stop"' WHERE dict_name='ispell_template';
17 --example of synonym dict:
18 -- UPDATE pg_ts_dict SET dict_initoption='/usr/local/share/ispell/english.syn' WHERE dict_id=5; 
19
20 --================================================================
21 --
22 -- Don't modify below this point unless you know what you are doing.
23 --
24 --================================================================
25
26 \set qprefix '\'' :prefix '\''
27 \set qhttp_user '\'' :httpd_user '\''
28 \echo '       prefix = ' :qprefix
29 \echo '   httpd_user = ' :qhttp_user
30
31 \set version_tbl        :prefix 'version'
32
33 GRANT SELECT ON pg_ts_dict, pg_ts_parser, pg_ts_cfg, pg_ts_cfgmap TO :httpd_user;
34 ALTER TABLE :version_tbl ADD COLUMN idxFTI tsvector;
35 UPDATE :version_tbl SET idxFTI=to_tsvector('default', content);
36 VACUUM FULL ANALYZE;
37 CREATE INDEX idxFTI_idx ON :version_tbl USING gist(idxFTI);
38 VACUUM FULL ANALYZE;
39 CREATE TRIGGER tsvectorupdate BEFORE UPDATE OR INSERT ON :version_tbl
40    FOR EACH ROW EXECUTE PROCEDURE tsearch2(idxFTI, content);