Skip to content

Instantly share code, notes, and snippets.

@stompro
Last active May 30, 2017 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stompro/7ec071490de8d7d227d472f0a0ce323b to your computer and use it in GitHub Desktop.
Save stompro/7ec071490de8d7d227d472f0a0ce323b to your computer and use it in GitHub Desktop.
Evergreen Synonym Dictionary Setup
Please files in the tsearch data directory, which differs based on postgres version.
Postgres 9.4 = /usr/share/postgresql/9.4/tsearch_data
Limitations - only single words can be mapped. So numbers over 20 cannot be mapped to their spelled out formats. To be clear, they can be mapped "21" -> "twenty-one" but the Evergreen search subsystem splits "twenty-one" into "Twenty" and "One" which won't ever match "Twenty-one" so it is pointless.
-- Create dictionaries
CREATE TEXT SEARCH DICTIONARY public.synonym_larl (template=pg_catalog.synonym, synonyms='synonym_larl');
CREATE TEXT SEARCH DICTIONARY public.synonym_larl_int (template=pg_catalog.synonym, synonyms='synonym_larl_int');
CREATE TEXT SEARCH DICTIONARY public.synonym_larl_int_roman (template=pg_catalog.synonym, synonyms='synonym_larl_int_roman');
CREATE TEXT SEARCH DICTIONARY public.synonym_larl_txt_roman (template=pg_catalog.synonym, synonyms='synonym_larl_txt_roman');
-- Create Tsearch configs - Need two, one for words, one for extra roman numeral mapping
CREATE TEXT SEARCH CONFIGURATION public.synonym_larl (copy=DEFAULT);
CREATE TEXT SEARCH CONFIGURATION public.synonym_larl_roman (copy=DEFAULT);
-- Map dictionaries to search config data types
ALTER TEXT SEARCH CONFIGURATION public.synonym_larl
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart
WITH synonym_larl;
ALTER TEXT SEARCH CONFIGURATION public.synonym_larl
ALTER MAPPING FOR uint
WITH synonym_larl_int;
ALTER TEXT SEARCH CONFIGURATION public.synonym_larl_roman
ALTER MAPPING FOR uint
WITH synonym_larl_int_roman;
ALTER TEXT SEARCH CONFIGURATION public.synonym_larl_roman
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart
WITH synonym_larl_txt_roman;
-- Insert search configs into Evergreen config list
INSERT INTO config.ts_config_list VALUES ('synonym_larl', 'LARL Synonym List');
INSERT INTO config.ts_config_list VALUES ('synonym_larl_roman', 'LARL Roman Numeral Synonym List');
-- Map evergreen search configs to indexes
INSERT INTO config.metabib_class_ts_map (field_class, ts_config, index_weight) VALUES
('keyword', 'synonym_larl', 'C'),
('title', 'synonym_larl', 'C'),
('subject', 'synonym_larl', 'C');
INSERT INTO config.metabib_class_ts_map (field_class, ts_config, index_weight) VALUES
('keyword', 'synonym_larl_roman', 'C'),
('title', 'synonym_larl_roman', 'C'),
('subject', 'synonym_larl_roman', 'C');
one 1
two 2
three 3
four 4
five 5
six 6
seven 7
eight 8
nine 9
ten 10
eleven 11
twelve 12
thirteen 13
fourteen 14
fifteen 15
sixteen 16
seventeen 17
eighteen 18
nineteen 19
twenty 20
thirty 30
forty 40
fifty 50
sixty 60
seventy 70
eighty 80
ninety 90
1st first
first 1st
2nd second
second 2nd
3rd third
third 3rd
4th fourth
fourth 4th
5th fifth
fifth 5th
6th sixth
sixth 6th
7th seventh
seventh 7th
8th eighth
eighth 8th
9th ninth
ninth 9th
10th tenth
tenth 10th
11th eleventh
eleventh 11th
12th twelfth
twelfth 12th
13th thirteenth
thirteenth 13th
14th fourteenth
fourteenth 14th
15th fifteenth
fifteenth 15th
16th sixteenth
sixteenth 16th
17th seventeenth
seventeenth 17th
18th eighteenth
eighteenth 18th
19th nineteenth
nineteenth 19th
20th twentieth
twentieth 20th
30th thirtieth
thirtieth 30th
40th fortieth
fortieth 40th
50th fiftieth
fiftieth 50th
60th sixtieth
sixtieth 60th
70th seventieth
seventieth 70th
80th eightieth
eightieth 80th
90th ninetieth
ninetieth 90th
colour color
color colour
favour favor
favor favour
favourite favorite
favorite favourite
encyclopaedia encyclopedia
encyclopedia encyclopaedia
medieval mediaeval
mediaeval medieval
amongst among
among amongst
dreamt dreamed
dreamed dreamt
ameba amoeba
amoeba ameba
foetus fetus
fetus foetus
whisky whiskey
whiskey whisky
judgement judgment
judgment judgement
theatre theater
theater theatre
chanukah hanukkah
hanukkah chanukah
child children
children child
cat cats
cats cat
dog dogs
dogs dog
mouse mice
mice mouse
horse horses
horses horse
cow cows
cows cow
duck ducks
ducks duck
chicken chickens
chickens chicken
puffin puffins
puffins puffin
penguin penguins
penguins penguin
& and
and &
mr mister
mister mr
mrs misses
missus mrs
mlle mademoiselle
madomoiselle mlle
doctor dr
dr doctor
sir sr
sr sir
professor prof
prof professor
i one
ii two
iii three
iv four
v five
vi six
vii seven
viii eight
ix nine
x ten
xi eleven
xii twelve
xiii thirteen
xiv fourteen
xv fifteen
xvi sixteen
xvii seventeen
xviii eighteen
xix nineteen
xx twenty
xxx thirty
xl forty
l fifty
lx sixty
lxx seventy
lxxx eighty
xc ninety
0 zero
1 one
2 two
3 three
4 four
5 five
6 six
7 seven
8 eight
9 nine
10 ten
11 eleven
12 twelve
13 thirteen
14 fourteen
15 fifteen
16 sixteen
17 seventeen
18 eighteen
19 nineteen
20 twenty
30 thirty
40 forty
50 fifty
60 sixty
70 seventy
80 eighty
90 ninety
1 i
2 ii
3 iii
4 iv
5 v
6 vi
7 vii
8 viii
9 iv
10 x
11 xi
12 xii
13 xiii
14 xiv
15 xv
16 xvi
17 xvii
18 xviii
19 xix
20 xx
21 xxi
22 xxii
23 xxiii
24 xxiv
25 xxv
26 xxvi
27 xxvii
28 xxviii
29 xxix
30 xxx
31 xxxi
32 xxxii
33 xxxiv
34 xxxiv
35 xxxv
36 xxxvi
37 xxxvii
38 xxxviii
39 xxxix
40 xl
41 xli
42 xlii
43 xliii
44 xliv
45 xlv
46 xlvi
47 xlvii
48 xlviii
49 xlix
50 l
51 li
52 lii
53 liii
54 liv
60 lx
66 lxvi
70 lxx
71 lxxi
72 lxxii
73 lxxiii
74 lxxiv
80 lxxx
90 xc
i 1
ii 2
iii 3
iv 4
v 5
vi 6
vii 7
viii 8
ix 9
x 10
xi 11
xii 12
xiii 13
xiv 14
xv 15
xvi 16
xvii 17
xviii 18
xix 19
xx 20
xxi 21
xxii 22
xxiii 23
xxiv 24
xxv 25
xxvi 26
xxvii 27
xxviii 28
xxix 29
xxx 30
xxxi 31
xxxii 32
xxxiv 33
xxxiv 34
xxxv 35
xxxvi 36
xxxvii 37
xxxviii 38
xxxix 39
xl 40
xli 41
xlii 42
xliii 43
xliv 44
xlv 45
xlvi 46
xlvii 47
xlviii 48
xlix 49
l 50
li 51
lii 52
liii 53
liv 54
lx 60
lxvi 66
lxx 70
lxxi 71
lxxii 72
lxxiii 73
lxxiv 74
lxxx 80
xc 90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment