summaryrefslogtreecommitdiff
path: root/contrib/test_parser/README.test_parser
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-10-15 21:36:50 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-10-15 21:36:50 +0000
commit5fcb079858bb392e87067b5526e9df950db38024 (patch)
tree4ffb764af092be94fbe0e033dce2f492e6c937f7 /contrib/test_parser/README.test_parser
parentfb631dba2a3c2c183bb99f2098491ecf96fb6664 (diff)
Add sample text search dictionary templates and parsers, to replace the
hard-to-maintain textual examples currently in the SGML docs. From Sergey Karpov.
Diffstat (limited to 'contrib/test_parser/README.test_parser')
-rw-r--r--contrib/test_parser/README.test_parser52
1 files changed, 52 insertions, 0 deletions
diff --git a/contrib/test_parser/README.test_parser b/contrib/test_parser/README.test_parser
new file mode 100644
index 00000000000..d8ca90a5df3
--- /dev/null
+++ b/contrib/test_parser/README.test_parser
@@ -0,0 +1,52 @@
+Example parser
+==============
+
+This is an example of a custom parser for full text search.
+
+It recognizes space-delimited words and returns only two token types:
+
+ - 3, word, Word
+
+ - 12, blank, Space symbols
+
+The token numbers have been chosen to keep compatibility with the default
+ts_headline() function, since we do not want to implement our own version.
+
+* Configuration
+
+The parser has no user-configurable parameters.
+
+* Usage
+
+1. Compile and install
+
+2. Load dictionary
+
+ psql mydb < test_parser.sql
+
+3. Test it
+
+ mydb# SELECT * FROM ts_parse('testparser','That''s my first own parser');
+ tokid | token
+ -------+--------
+ 3 | That's
+ 12 |
+ 3 | my
+ 12 |
+ 3 | first
+ 12 |
+ 3 | own
+ 12 |
+ 3 | parser
+
+ mydb# SELECT to_tsvector('testcfg','That''s my first own parser');
+ to_tsvector
+ -------------------------------------------------
+ 'my':2 'own':4 'first':3 'parser':5 'that''s':1
+
+ mydb# SELECT ts_headline('testcfg','Supernovae stars are the brightest phenomena in galaxies', to_tsquery('testcfg', 'star'));
+ headline
+ -----------------------------------------------------------------
+ Supernovae <b>stars</b> are the brightest phenomena in galaxies
+
+That's all.