pg_pinyin
概览
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 2200 | pg_pinyin | 否 | 是 | 否 | 是 | 否 | 是 | pinyin |
optional tokenizer-input overload can integrate with pg_search.
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.0.8 | 1817161514 | pg_pinyin | - |
| RPM | PIGSTY | 0.0.8 | 1817161514 | pg_pinyin_$v | - |
| DEB | PIGSTY | 0.0.8 | 1817161514 | postgresql-$v-pinyin | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.0.8 el8.x86_64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 0.0.8 el8.aarch64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 0.0.8 el9.x86_64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 0.0.8 el9.aarch64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY 0.0.8 el10.x86_64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el10.x86_64.rpm
|
| el10.aarch64 | PIGSTY 0.0.8 el10.aarch64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el10.aarch64.rpm
|
| d12.x86_64 | PIGSTY 0.0.8 d12.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 0.0.8 d12.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY 0.0.8 d13.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
|
| d13.aarch64 | PIGSTY 0.0.8 d13.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
|
| u22.x86_64 | PIGSTY 0.0.8 u22.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 0.0.8 u22.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 0.0.8 u24.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 0.0.8 u24.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~noble_arm64.deb
|
| u26.x86_64 | PIGSTY 0.0.8 u26.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
|
| u26.aarch64 | PIGSTY 0.0.8 u26.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
|
构建
您可以使用 pig build 命令构建 pg_pinyin 扩展的 RPM / DEB 包:
安装
您可以直接安装 pg_pinyin 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
使用 pig 或者是 apt/yum/dnf 安装扩展:
创建扩展:
用法
来源:
- pg_pinyin v0.0.8 README
- pg_pinyin v0.0.8 control file
- 0.0.7 到 0.0.8 升级 SQL
- 0.0.8 parallel read-only regression
- 0.0.8 implementation
pg_pinyin 对中文文本进行拉丁化,并提供分词器和查询辅助工具,适用于搜索应用。使用 pg_pinyin 可以创建稳定的拼音搜索键、分汉字文本或扩展拼音输入为 pg_search 正则表达式查询。
0.0.8 修复了并行拼音转换、分词器转换及后缀词典查询中的只读 SPI 调用。该版本使用 pgrx 0.19.3,支持 PostgreSQL 14-18 和 PostgreSQL 19 beta4。随版本提供的 0.0.7 到 0.0.8 迁移脚本不修改 SQL 对象,运行时修复位于共享库中。安装新版本扩展文件后,执行 ALTER EXTENSION pg_pinyin UPDATE TO ‘0.0.8’。Pigsty 包元数据单独维护。
创建扩展
CREATE EXTENSION pg_pinyin;
该扩展是可重定位的,并不需要 shared_preload_libraries 或服务器重启。
拉丁化文本
逐字符拉丁化或使用词感知分割:
SELECT pinyin_char_romanize('重庆');
SELECT pinyin_word_romanize('重庆火锅');
SELECT pinyin_word_romanize('重庆火锅', '_custom');
可选的 suffix 参数用于选择自定义词典表,不是输出分隔符。例如,_custom 对应 pinyin.pinyin_mapping_custom 和 pinyin.pinyin_words_custom,其中的条目优先于内置词典。词模式使用词典分词处理上下文读音。修改这些表后,调用 public.pinyin_clear_suffix_cache(’_custom’) 清理后缀词典缓存。
使用 pg_search 分词器输入
当安装了 pg_search 时,词拉丁化也接受 pg_search 分词器的结果:
SELECT pinyin_word_romanize(
description::pdb.icu::text[]
)
FROM documents;
该重载返回拉丁化文本;它不暴露每分词一行的 API。在不需要 pg_search 分词的情况下使用纯文本重载。
构建一个 pg_search 查询
如果在安装 pg_pinyin 之前已安装了 pg_search,pg_pinyin 提供了一个类型化的重载,返回 pdb.query:
SELECT *
FROM documents
WHERE id @@@ pinyin_regex_phrase(
'chong qing',
slope => 1,
max_expansions => 64,
generated_pinyin => true
);
如果未安装 pg_search,则相同的入口点将作为错误报告的占位符而不是静默返回不同类型的值。在升级后按预期顺序安装依赖项并测试函数签名。
对象索引
- pinyin_char_romanize(text [, suffix]) 返回基于字符的拼音文本。
- pinyin_word_romanize(text [, suffix]) 返回词典分割的拼音文本。
- pinyin_word_romanize(tokenizer_input [, suffix]) 接受一个 pg_search 分词器结果。
- pinyin_regex_phrase(text, slope, max_expansions, generated_pinyin) 当该集成可用时,构建一个 pg_search 拼音短语查询。
- pinyin_regex_phrase_patterns 是一个内部模式构建辅助函数;请优先使用公共查询函数。
运行注意事项
扩展在其 pinyin 模式中自带生成的字符和词字典。将这些表视为由扩展管理的数据,而不是应用程序表。拉丁化是规范化,不是翻译,并且可能需要应用端审查以处理模糊或领域特定的读音。
这个页面对您有帮助吗?
感谢反馈,我们会据此改进这篇文档。
哪里没有解决?(可选)