pg_scws
a parser for full-text search of Chinese
pg_scws · a parser for full-text search of Chinese
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100109 | pg_scws | pg_scws | 1.0 | FTS | BSD-3-Clause | C |
Usage
Sources:
- Official README at the catalog revision
- Extension SQL at the catalog revision
- Parser implementation at the catalog revision
pg_scws 1.0 integrates the SCWS Chinese word segmenter as a PostgreSQL full-text-search parser. It installs the scws parser and the scwscfg text-search configuration, which maps several lexical classes through the simple dictionary.
Core Workflow
Use the same text-search configuration in the indexed expression and every matching query.
Objects and Settings
- The extension creates the scws text-search parser and scwscfg configuration.
- Settings control dictionary-in-memory mode, charset selection, rules file, extra dictionaries, punctuation handling, duality segmentation, and multi-mode segmentation.
- Dictionary and rule files are resolved from PostgreSQL’s text-search data directory. Every server that can execute queries needs identical files and configuration.
Compatibility and Operations
- Upstream reports testing only on PostgreSQL 9.4 and merely expects later 9.x versions to work. The parser uses server APIs that can change between major versions; build and test it on each exact target major.
- The source bundles SCWS, a default UTF-8 dictionary, and rules. Custom dictionaries should be deployed atomically across primary, replicas, and failover candidates before rebuilding affected indexes.
- Segmentation or dictionary changes alter lexemes. REINDEX expression indexes after intentional rule changes and validate search recall/precision with representative Chinese text.