thai_parser
thai_parser · Thai-language parser and text search configuration for PostgreSQL full-text search.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101187 | thai_parser | thai_parser | 1.0.0 | FTS | Unknown | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
thai_parser supplies Thai word segmentation for PostgreSQL full-text search, where spaces do not reliably mark word boundaries. It creates the parser thai_parser and the ready-to-use configuration thaicfg; the extension requires libthai and an UTF-8 database.
Core Workflow
Create the extension, derive a stored search vector, and index it with GIN:
Use a bound parameter and an appropriate query constructor for application input. to_tsquery expects full text-search syntax; use plainto_tsquery when users should not supply operators.
Important Objects
thai_parseris both the extension name and the installed text-search parser.thaicfgis the default text-search configuration created by the extension.ts_parseexposes tokenizer output for diagnosis. Token IDs 97, 98, and 99 represent Thai words, ASCII words, and spaces respectively.- The default
thaicfgmapping indexes Thai-word tokens only. Add and test anasciiwordmapping in a separate text-search configuration when mixed Thai/English content must be searchable.
Prerequisites and Caveats
The server build needs the libthai development/runtime library used by the parser, and the database encoding must be UTF-8. These are host-level requirements, so a database dump alone is insufficient for restore onto a new server.
The upstream repository also contains optional Hunspell dictionary assets, but they are not required for parser-only use. Thai segmentation and dictionary choices affect indexed lexemes; after changing the extension, dictionary, or mapping, rebuild affected text-search indexes and regression-test representative spelling, compound words, mixed-language text, ranking, and transactional search behavior.