| 1 |
CREATE EXTENSION test_parser; |
| 2 |
-- make test configuration using parser |
| 3 |
CREATE TEXT SEARCH CONFIGURATION testcfg (PARSER = testparser); |
| 4 |
ALTER TEXT SEARCH CONFIGURATION testcfg ADD MAPPING FOR word WITH simple; |
| 5 |
-- ts_parse |
| 6 |
SELECT * FROM ts_parse('testparser', 'That''s simple parser can''t parse urls like http://some.url/here/'); |
| 7 |
tokid | token |
| 8 |
-------+----------------------- |
| 9 |
3 | That's |
| 10 |
12 | |
| 11 |
3 | simple |
| 12 |
12 | |
| 13 |
3 | parser |
| 14 |
12 | |
| 15 |
3 | can't |
| 16 |
12 | |
| 17 |
3 | parse |
| 18 |
12 | |
| 19 |
3 | urls |
| 20 |
12 | |
| 21 |
3 | like |
| 22 |
12 | |
| 23 |
3 | http://some.url/here/ |
| 24 |
(15 rows) |
| 25 |
|
| 26 |
SELECT to_tsvector('testcfg','That''s my first own parser'); |
| 27 |
to_tsvector |
| 28 |
------------------------------------------------- |
| 29 |
'first':3 'my':2 'own':4 'parser':5 'that''s':1 |
| 30 |
(1 row) |
| 31 |
|
| 32 |
SELECT to_tsquery('testcfg', 'star'); |
| 33 |
to_tsquery |
| 34 |
------------ |
| 35 |
'star' |
| 36 |
(1 row) |
| 37 |
|
| 38 |
SELECT ts_headline('testcfg','Supernovae stars are the brightest phenomena in galaxies', |
| 39 |
to_tsquery('testcfg', 'stars')); |
| 40 |
ts_headline |
| 41 |
----------------------------------------------------------------- |
| 42 |
Supernovae <b>stars</b> are the brightest phenomena in galaxies |
| 43 |
(1 row) |
| 44 |
|