]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/000.english.pg94.fts-config.sql
lp1863252 toward geosort
[Evergreen.git] / Open-ILS / src / sql / Pg / 000.english.pg94.fts-config.sql
1 /*
2  * Copyright (C) 2004-2008  Georgia Public Library Service
3  * Copyright (C) 2008  Equinox Software, Inc., Laurentian University
4  * Mike Rylander <miker@esilibrary.com>
5  * Dan Scott <dscott@laurentian.ca>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  */
18
19 BEGIN;
20
21 SET search_path = public, pg_catalog;
22
23 CREATE OR REPLACE FUNCTION oils_tsearch2 () RETURNS TRIGGER AS $$
24 BEGIN
25         NEW.index_vector = to_tsvector((TG_ARGV[0])::regconfig, NEW.value);
26         RETURN NEW;
27 END;
28 $$ LANGUAGE PLPGSQL;
29
30 DO $$
31 DECLARE
32 lang TEXT;
33 BEGIN
34 FOR lang IN SELECT substring(pptsd.dictname from '(.*)_stem$') AS lang FROM pg_catalog.pg_ts_dict pptsd JOIN pg_catalog.pg_namespace ppn ON ppn.oid = pptsd.dictnamespace
35 WHERE ppn.nspname = 'pg_catalog' AND pptsd.dictname LIKE '%_stem' LOOP
36 RAISE NOTICE 'FOUND LANGUAGE %', lang;
37
38 EXECUTE 'DROP TEXT SEARCH DICTIONARY IF EXISTS ' || lang || '_nostop CASCADE;
39 CREATE TEXT SEARCH DICTIONARY ' || lang || '_nostop (TEMPLATE=pg_catalog.snowball, language=''' || lang || ''');
40 COMMENT ON TEXT SEARCH DICTIONARY ' || lang || '_nostop IS ''' ||lang || ' snowball stemmer with no stopwords for ASCII words only.'';
41 CREATE TEXT SEARCH CONFIGURATION ' || lang || '_nostop ( COPY = pg_catalog.' || lang || ' );
42 ALTER TEXT SEARCH CONFIGURATION ' || lang || '_nostop ALTER MAPPING FOR word, hword, hword_part WITH pg_catalog.simple;
43 ALTER TEXT SEARCH CONFIGURATION ' || lang || '_nostop ALTER MAPPING FOR asciiword, asciihword, hword_asciipart WITH ' || lang || '_nostop;';
44
45 END LOOP;
46 END;
47 $$;
48 CREATE TEXT SEARCH CONFIGURATION title ( COPY = english_nostop );
49 CREATE TEXT SEARCH CONFIGURATION author ( COPY = english_nostop );
50 CREATE TEXT SEARCH CONFIGURATION subject ( COPY = english_nostop );
51 CREATE TEXT SEARCH CONFIGURATION keyword ( COPY = english_nostop );
52 CREATE TEXT SEARCH CONFIGURATION identifier ( COPY = english_nostop );
53 CREATE TEXT SEARCH CONFIGURATION series ( COPY = english_nostop );
54 CREATE TEXT SEARCH CONFIGURATION "default" ( COPY = english_nostop );
55
56
57 COMMIT;