Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / test / regress / sql / tsdicts.sql
blobf36e63a31107ef024328b8ea9b43e9bfe31fde45
1 --Test text search dictionaries and configurations
3 -- Test ISpell dictionary with ispell affix file
4 CREATE TEXT SEARCH DICTIONARY ispell (
5                         Template=ispell,
6                         DictFile=ispell_sample,
7                         AffFile=ispell_sample
8 );
10 SELECT ts_lexize('ispell', 'skies');
11 SELECT ts_lexize('ispell', 'bookings');
12 SELECT ts_lexize('ispell', 'booking');
13 SELECT ts_lexize('ispell', 'foot');
14 SELECT ts_lexize('ispell', 'foots');
15 SELECT ts_lexize('ispell', 'rebookings');
16 SELECT ts_lexize('ispell', 'rebooking');
17 SELECT ts_lexize('ispell', 'rebook');
18 SELECT ts_lexize('ispell', 'unbookings');
19 SELECT ts_lexize('ispell', 'unbooking');
20 SELECT ts_lexize('ispell', 'unbook');
22 SELECT ts_lexize('ispell', 'footklubber');
23 SELECT ts_lexize('ispell', 'footballklubber');
24 SELECT ts_lexize('ispell', 'ballyklubber');
25 SELECT ts_lexize('ispell', 'footballyklubber');
27 -- Test ISpell dictionary with hunspell affix file
28 CREATE TEXT SEARCH DICTIONARY hunspell (
29                         Template=ispell,
30                         DictFile=ispell_sample,
31                         AffFile=hunspell_sample
34 SELECT ts_lexize('hunspell', 'skies');
35 SELECT ts_lexize('hunspell', 'bookings');
36 SELECT ts_lexize('hunspell', 'booking');
37 SELECT ts_lexize('hunspell', 'foot');
38 SELECT ts_lexize('hunspell', 'foots');
39 SELECT ts_lexize('hunspell', 'rebookings');
40 SELECT ts_lexize('hunspell', 'rebooking');
41 SELECT ts_lexize('hunspell', 'rebook');
42 SELECT ts_lexize('hunspell', 'unbookings');
43 SELECT ts_lexize('hunspell', 'unbooking');
44 SELECT ts_lexize('hunspell', 'unbook');
46 SELECT ts_lexize('hunspell', 'footklubber');
47 SELECT ts_lexize('hunspell', 'footballklubber');
48 SELECT ts_lexize('hunspell', 'ballyklubber');
49 SELECT ts_lexize('hunspell', 'footballyklubber');
51 -- Synonim dictionary
52 CREATE TEXT SEARCH DICTIONARY synonym (
53                                                 Template=synonym, 
54                                                 Synonyms=synonym_sample
57 SELECT ts_lexize('synonym', 'PoStGrEs');
58 SELECT ts_lexize('synonym', 'Gogle');
60 -- Create and simple test thesaurus dictionary
61 -- More tests in configuration checks because ts_lexize()
62 -- cannot pass more than one word to thesaurus.
63 CREATE TEXT SEARCH DICTIONARY thesaurus (
64                         Template=thesaurus,
65                                                 DictFile=thesaurus_sample, 
66                                                 Dictionary=english_stem
69 SELECT ts_lexize('thesaurus', 'one');
71 -- Test ispell dictionary in configuration
72 CREATE TEXT SEARCH CONFIGURATION ispell_tst (
73                                                 COPY=english
76 ALTER TEXT SEARCH CONFIGURATION ispell_tst ALTER MAPPING FOR
77         word, numword, asciiword, hword, numhword, asciihword, hword_part, hword_numpart, hword_asciipart
78         WITH ispell, english_stem;
80 SELECT to_tsvector('ispell_tst', 'Booking the skies after rebookings for footballklubber from a foot');
81 SELECT to_tsquery('ispell_tst', 'footballklubber');
82 SELECT to_tsquery('ispell_tst', 'footballyklubber:b & rebookings:A & sky');
84 -- Test ispell dictionary with hunspell affix in configuration
85 CREATE TEXT SEARCH CONFIGURATION hunspell_tst (
86                                                 COPY=ispell_tst
89 ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING
90         REPLACE ispell WITH hunspell;
92 SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot');
93 SELECT to_tsquery('hunspell_tst', 'footballklubber');
94 SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky');
96 -- Test synonym dictionary in configuration
97 CREATE TEXT SEARCH CONFIGURATION synonym_tst (
98                                                 COPY=english
101 ALTER TEXT SEARCH CONFIGURATION synonym_tst ALTER MAPPING FOR 
102         asciiword, hword_asciipart, asciihword 
103         WITH synonym, english_stem;
105 SELECT to_tsvector('synonym_tst', 'Postgresql is often called as postgres or pgsql and pronounced as postgre');
106 SELECT to_tsvector('synonym_tst', 'Most common mistake is to write Gogle instead of Google');
108 -- test thesaurus in configuration
109 -- see thesaurus_sample.ths to understand 'odd' resulting tsvector
110 CREATE TEXT SEARCH CONFIGURATION thesaurus_tst (
111                                                 COPY=synonym_tst
114 ALTER TEXT SEARCH CONFIGURATION thesaurus_tst ALTER MAPPING FOR 
115         asciiword, hword_asciipart, asciihword 
116         WITH synonym, thesaurus, english_stem;
118 SELECT to_tsvector('thesaurus_tst', 'one postgres one two one two three one');
119 SELECT to_tsvector('thesaurus_tst', 'Supernovae star is very new star and usually called supernovae (abbrevation SN)');
120 SELECT to_tsvector('thesaurus_tst', 'Booking tickets is looking like a booking a tickets');