-
Notifications
You must be signed in to change notification settings - Fork 5
/
tsexample--1.0.sql
62 lines (51 loc) · 1.82 KB
/
tsexample--1.0.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* contrib/tsexample/tsexample--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION tsexample;" to load this file. \quit
CREATE OR REPLACE FUNCTION sparser_start(internal, integer)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE OR REPLACE FUNCTION sparser_nexttoken(internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE OR REPLACE FUNCTION sparser_end(internal)
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE OR REPLACE FUNCTION sparser_lextype(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE TEXT SEARCH PARSER sample_parser (
START = sparser_start,
GETTOKEN = sparser_nexttoken,
END = sparser_end,
LEXTYPES = sparser_lextype
);
COMMENT ON TEXT SEARCH PARSER sample_parser IS 'sample word parser';
CREATE OR REPLACE FUNCTION cutdict_init(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE OR REPLACE FUNCTION cutdict_lexize(internal, internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE TEXT SEARCH TEMPLATE cutdict (
INIT = cutdict_init,
LEXIZE = cutdict_lexize
);
COMMENT ON TEXT SEARCH TEMPLATE cutdict IS 'cut dictionary: lowercase and keep only beginning and ending of long words';
CREATE TEXT SEARCH DICTIONARY cut3 (
TEMPLATE = cutdict,
nbegin = 3,
nend = 3
);
COMMENT ON TEXT SEARCH DICTIONARY cut3 IS 'cut dictionary with nbegin = nend = 3';
CREATE TEXT SEARCH CONFIGURATION sample (
PARSER = "sample_parser"
);
ALTER TEXT SEARCH CONFIGURATION sample ADD MAPPING FOR word WITH cut3;
ALTER TEXT SEARCH CONFIGURATION sample ADD MAPPING FOR number WITH simple;
COMMENT ON TEXT SEARCH CONFIGURATION sample IS 'sample configuration';