- publishing free software manuals
The PostgreSQL 9.0 Reference Manual - Volume 1A - SQL Language Reference
by The PostgreSQL Global Development Group
Paperback (6"x9"), 454 pages
ISBN 9781906966041
RRP £14.95 ($19.95)

Sales of this book support the PostgreSQL project! Get a printed copy>>>

10.8.2 Parser Testing

The following functions allow direct testing of a text search parser.

ts_parse(parser_name text, document text,
         OUT tokid integer, OUT token text) returns setof record
ts_parse(parser_oid oid, document text,
         OUT tokid integer, OUT token text) returns setof record

ts_parse parses the given document and returns a series of records, one for each token produced by parsing. Each record includes a tokid showing the assigned token type and a token which is the text of the token. For example:

SELECT * FROM ts_parse('default', '123 - a number');
 tokid | token
-------+--------
    22 | 123
    12 |
    12 | -
     1 | a
    12 |
     1 | number
ts_token_type(parser_name text, OUT tokid integer,
              OUT alias text, OUT description text) returns
 setof record
ts_token_type(parser_oid oid, OUT tokid integer,
              OUT alias text, OUT description text) returns
 setof record

ts_token_type returns a table which describes each type of token the specified parser can recognize. For each token type, the table gives the integer tokid that the parser uses to label a token of that type, the alias that names the token type in configuration commands, and a short description. For example:

SELECT * FROM ts_token_type('default');
 tokid |      alias      |
-------+-----------------+
     1 | asciiword       |
     2 | word            |
     3 | numword         |
     4 | email           |
     5 | url             |
     6 | host            |
     7 | sfloat          |
     8 | version         |
     9 | hword_numpart   |
    10 | hword_part      |
    11 | hword_asciipart |
    12 | blank           |
    13 | tag             |
    14 | protocol        |
    15 | numhword        |
    16 | asciihword      |
    17 | hword           |
    18 | url_path        |
    19 | file            |
    20 | float           |
    21 | int             |
    22 | uint            |
    23 | entity          |
               description
------------------------------------------
 Word, all ASCII
 Word, all letters
 Word, letters and digits
 Email address
 URL
 Host
 Scientific notation
 Version number
 Hyphenated word part, letters and digits
 Hyphenated word part, all letters
 Hyphenated word part, all ASCII
 Space symbols
 XML tag
 Protocol head
 Hyphenated word, letters and digits
 Hyphenated word, all ASCII
 Hyphenated word, all letters
 URL path
 File or path name
 Decimal notation
 Signed integer
 Unsigned integer
 XML entity
ISBN 9781906966041The PostgreSQL 9.0 Reference Manual - Volume 1A - SQL Language ReferenceSee the print edition