跳转到主要内容

pg_icu_parser

使用 ICU 边界分析的全文搜索解析器

pg_icu_parser · 使用 ICU 边界分析的全文搜索解析器

概览

ID扩展软件包版本类别许可证编程语言
2300pg_icu_parserpg_icu_parser1.0FTSMPL-2.0C
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d-r否是否是是否
ts_headline unsupported.

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY1.019 18 17 16 15pg_icu_parser-
RPMPIGSTY1.0.019 18 17 16 15pg_icu_parser_$v-
DEBPIGSTY1.0.019 18 17 16 15postgresql-$v-pg-icu-parser-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el8.aarch64N/APIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el9.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el9.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el10.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el10.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d12.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d12.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d13.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d13.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u22.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u22.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u24.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u24.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u26.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u26.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
软件包版本平台仓库大小下载
pg_icu_parser_191.0.0el9.x86_64pigsty29.0 KiBpg_icu_parser_19-1.0.0-1PGSTY.el9.x86_64.rpm
pg_icu_parser_191.0.0el9.aarch64pigsty28.8 KiBpg_icu_parser_19-1.0.0-1PGSTY.el9.aarch64.rpm
pg_icu_parser_191.0.0el10.x86_64pigsty28.6 KiBpg_icu_parser_19-1.0.0-1PGSTY.el10.x86_64.rpm
pg_icu_parser_191.0.0el10.aarch64pigsty28.9 KiBpg_icu_parser_19-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-icu-parser1.0.0d12.x86_64pigsty20.0 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-icu-parser1.0.0d12.aarch64pigsty19.8 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-icu-parser1.0.0d13.x86_64pigsty20.0 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-icu-parser1.0.0d13.aarch64pigsty19.9 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-icu-parser1.0.0u22.x86_64pigsty20.8 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-icu-parser1.0.0u22.aarch64pigsty20.9 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-icu-parser1.0.0u24.x86_64pigsty21.0 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-icu-parser1.0.0u24.aarch64pigsty20.5 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-icu-parser1.0.0u26.x86_64pigsty20.7 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-icu-parser1.0.0u26.aarch64pigsty20.9 KiBpostgresql-19-pg-icu-parser_1.0.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_icu_parser_181.0.0el8.x86_64pigsty28.2 KiBpg_icu_parser_18-1.0.0-1PGSTY.el8.x86_64.rpm
pg_icu_parser_181.0.0el8.aarch64pigsty28.6 KiBpg_icu_parser_18-1.0.0-1PGSTY.el8.aarch64.rpm
pg_icu_parser_181.0.0el9.x86_64pigsty29.0 KiBpg_icu_parser_18-1.0.0-1PGSTY.el9.x86_64.rpm
pg_icu_parser_181.0.0el9.aarch64pigsty28.8 KiBpg_icu_parser_18-1.0.0-1PGSTY.el9.aarch64.rpm
pg_icu_parser_181.0.0el10.x86_64pigsty28.6 KiBpg_icu_parser_18-1.0.0-1PGSTY.el10.x86_64.rpm
pg_icu_parser_181.0.0el10.aarch64pigsty28.9 KiBpg_icu_parser_18-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-icu-parser1.0.0d12.x86_64pigsty20.0 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-icu-parser1.0.0d12.aarch64pigsty19.9 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-icu-parser1.0.0d13.x86_64pigsty20.0 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-icu-parser1.0.0d13.aarch64pigsty19.9 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-icu-parser1.0.0u22.x86_64pigsty20.8 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-icu-parser1.0.0u22.aarch64pigsty20.9 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-icu-parser1.0.0u24.x86_64pigsty21.0 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-icu-parser1.0.0u24.aarch64pigsty20.5 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-icu-parser1.0.0u26.x86_64pigsty20.7 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-icu-parser1.0.0u26.aarch64pigsty20.9 KiBpostgresql-18-pg-icu-parser_1.0.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_icu_parser_171.0.0el8.x86_64pigsty28.2 KiBpg_icu_parser_17-1.0.0-1PGSTY.el8.x86_64.rpm
pg_icu_parser_171.0.0el8.aarch64pigsty28.5 KiBpg_icu_parser_17-1.0.0-1PGSTY.el8.aarch64.rpm
pg_icu_parser_171.0.0el9.x86_64pigsty29.0 KiBpg_icu_parser_17-1.0.0-1PGSTY.el9.x86_64.rpm
pg_icu_parser_171.0.0el9.aarch64pigsty28.8 KiBpg_icu_parser_17-1.0.0-1PGSTY.el9.aarch64.rpm
pg_icu_parser_171.0.0el10.x86_64pigsty28.6 KiBpg_icu_parser_17-1.0.0-1PGSTY.el10.x86_64.rpm
pg_icu_parser_171.0.0el10.aarch64pigsty28.8 KiBpg_icu_parser_17-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-icu-parser1.0.0d12.x86_64pigsty19.9 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-icu-parser1.0.0d12.aarch64pigsty19.8 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-icu-parser1.0.0d13.x86_64pigsty19.9 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-icu-parser1.0.0d13.aarch64pigsty19.9 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-icu-parser1.0.0u22.x86_64pigsty21.5 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-icu-parser1.0.0u22.aarch64pigsty21.6 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-icu-parser1.0.0u24.x86_64pigsty21.0 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-icu-parser1.0.0u24.aarch64pigsty20.4 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-icu-parser1.0.0u26.x86_64pigsty20.7 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-icu-parser1.0.0u26.aarch64pigsty20.9 KiBpostgresql-17-pg-icu-parser_1.0.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_icu_parser_161.0.0el8.x86_64pigsty28.1 KiBpg_icu_parser_16-1.0.0-1PGSTY.el8.x86_64.rpm
pg_icu_parser_161.0.0el8.aarch64pigsty28.5 KiBpg_icu_parser_16-1.0.0-1PGSTY.el8.aarch64.rpm
pg_icu_parser_161.0.0el9.x86_64pigsty29.0 KiBpg_icu_parser_16-1.0.0-1PGSTY.el9.x86_64.rpm
pg_icu_parser_161.0.0el9.aarch64pigsty28.8 KiBpg_icu_parser_16-1.0.0-1PGSTY.el9.aarch64.rpm
pg_icu_parser_161.0.0el10.x86_64pigsty28.6 KiBpg_icu_parser_16-1.0.0-1PGSTY.el10.x86_64.rpm
pg_icu_parser_161.0.0el10.aarch64pigsty28.8 KiBpg_icu_parser_16-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-icu-parser1.0.0d12.x86_64pigsty20.0 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-icu-parser1.0.0d12.aarch64pigsty19.8 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-icu-parser1.0.0d13.x86_64pigsty19.9 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-icu-parser1.0.0d13.aarch64pigsty19.9 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-icu-parser1.0.0u22.x86_64pigsty21.5 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-icu-parser1.0.0u22.aarch64pigsty21.6 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-icu-parser1.0.0u24.x86_64pigsty21.0 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-icu-parser1.0.0u24.aarch64pigsty20.4 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-icu-parser1.0.0u26.x86_64pigsty20.7 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-icu-parser1.0.0u26.aarch64pigsty20.9 KiBpostgresql-16-pg-icu-parser_1.0.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_icu_parser_151.0.0el8.x86_64pigsty28.2 KiBpg_icu_parser_15-1.0.0-1PGSTY.el8.x86_64.rpm
pg_icu_parser_151.0.0el8.aarch64pigsty28.5 KiBpg_icu_parser_15-1.0.0-1PGSTY.el8.aarch64.rpm
pg_icu_parser_151.0.0el9.x86_64pigsty29.0 KiBpg_icu_parser_15-1.0.0-1PGSTY.el9.x86_64.rpm
pg_icu_parser_151.0.0el9.aarch64pigsty28.8 KiBpg_icu_parser_15-1.0.0-1PGSTY.el9.aarch64.rpm
pg_icu_parser_151.0.0el10.x86_64pigsty28.6 KiBpg_icu_parser_15-1.0.0-1PGSTY.el10.x86_64.rpm
pg_icu_parser_151.0.0el10.aarch64pigsty28.8 KiBpg_icu_parser_15-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-icu-parser1.0.0d12.x86_64pigsty20.1 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-icu-parser1.0.0d12.aarch64pigsty19.8 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-icu-parser1.0.0d13.x86_64pigsty20.0 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-icu-parser1.0.0d13.aarch64pigsty19.9 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-icu-parser1.0.0u22.x86_64pigsty21.5 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-icu-parser1.0.0u22.aarch64pigsty21.6 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-icu-parser1.0.0u24.x86_64pigsty21.1 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-icu-parser1.0.0u24.aarch64pigsty20.4 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-icu-parser1.0.0u26.x86_64pigsty20.7 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-icu-parser1.0.0u26.aarch64pigsty20.9 KiBpostgresql-15-pg-icu-parser_1.0.0-1PGSTY~resolute_arm64.deb

源码

pig build pkg pg_icu_parser;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install pg_icu_parser;		# install by package name

pig install pg_icu_parser -v 19;   # install for PG 19
pig install pg_icu_parser -v 18;   # install for PG 18
pig install pg_icu_parser -v 17;   # install for PG 17
pig install pg_icu_parser -v 16;   # install for PG 16
pig install pg_icu_parser -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION pg_icu_parser;

用法

来源:

pg_icu_parser 提供采用 ICU Unicode 单词边界分析的 icu_parser 全文搜索解析器。它适用于中文、日文、韩文和希伯来文等语言,因为 PostgreSQL 默认解析器以空白和模式为中心,可能无法产生合适的单词边界。

核心流程

服务器必须是 PostgreSQL 10 或更高版本,并且构建时已经启用 ICU。创建扩展后,建立使用该解析器的文本搜索配置,再映射所需的词元类型:

CREATE EXTENSION pg_icu_parser;

CREATE TEXT SEARCH CONFIGURATION sample (PARSER = icu_parser);
ALTER TEXT SEARCH CONFIGURATION sample
  ADD MAPPING FOR word WITH english_stem;
ALTER TEXT SEARCH CONFIGURATION sample
  ADD MAPPING FOR number, ideo, kana WITH simple;

SELECT to_tsvector('sample', '東京でPostgreSQLを使う');

应为实际语言选择词典;上面的 english_stem 只用于演示映射语法。

解析器接口

  • word、number、kana、ideo 和 blank 是 icu_parser 输出的词元类型。
  • pg_icu_parser.locale 选择 ICU locale,默认值为 en。上游指出单词边界规则通常不依赖 locale,因此只有在验证了具体需求后才应修改。
  • 任意 PostgreSQL 文本搜索词典都可以映射到这些输出词元类型。

取舍

  • 解析器要求 PostgreSQL 构建已经包含 ICU;创建扩展无法为未启用 ICU 的服务器补上该能力。
  • 与默认解析器相比,它输出的词元类型更少、更粗,也不会把 URL、电子邮件等特殊模式识别为独立类别。
  • 当前审阅的版本不支持 ts_headline。
  • 上游报告其速度慢于默认解析器,而数据库编码为 UTF-8 时转换开销会较低。应在目标系统上用有代表性的文档和查询形态进行基准测试。
  • 修改解析器映射或 locale 行为后,应重建已存储的 tsvector 值和依赖索引,避免新旧行采用不同分词规则。

表格阅读器