跳转到主要内容

pg_kazsearch

PostgreSQL 哈萨克语全文检索扩展

pg_kazsearch · PostgreSQL 哈萨克语全文检索扩展

概览

ID扩展软件包版本类别许可证编程语言
2210pg_kazsearchpg_kazsearch2.3.0FTSLGPL-3.0Rust
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d--否是否是否否

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY2.3.019 18 17 16 15pg_kazsearch-
RPMPIGSTY2.3.019 18 17 16 15pg_kazsearch_$v-
DEBPIGSTY2.3.019 18 17 16 15postgresql-$v-pg-kazsearch-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
el8.aarch64N/APIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
el9.x86_64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
el9.aarch64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
el10.x86_64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
el10.aarch64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
d12.x86_64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
d12.aarch64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
d13.x86_64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
d13.aarch64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
u22.x86_64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
u22.aarch64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
u24.x86_64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
u24.aarch64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
u26.x86_64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
u26.aarch64PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0PIGSTY 2.3.0N/A
软件包版本平台仓库大小下载
pg_kazsearch_192.3.0el9.x86_64pigsty1.1 MiBpg_kazsearch_19-2.3.0-2PGSTY.el9.x86_64.rpm
pg_kazsearch_192.3.0el9.aarch64pigsty1.1 MiBpg_kazsearch_19-2.3.0-2PGSTY.el9.aarch64.rpm
pg_kazsearch_192.3.0el10.x86_64pigsty1.1 MiBpg_kazsearch_19-2.3.0-2PGSTY.el10.x86_64.rpm
pg_kazsearch_192.3.0el10.aarch64pigsty1.1 MiBpg_kazsearch_19-2.3.0-2PGSTY.el10.aarch64.rpm
postgresql-19-pg-kazsearch2.3.0d12.x86_64pigsty764.3 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~bookworm_amd64.deb
postgresql-19-pg-kazsearch2.3.0d12.aarch64pigsty686.5 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~bookworm_arm64.deb
postgresql-19-pg-kazsearch2.3.0d13.x86_64pigsty764.7 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~trixie_amd64.deb
postgresql-19-pg-kazsearch2.3.0d13.aarch64pigsty687.8 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~trixie_arm64.deb
postgresql-19-pg-kazsearch2.3.0u22.x86_64pigsty854.5 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~jammy_amd64.deb
postgresql-19-pg-kazsearch2.3.0u22.aarch64pigsty808.7 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~jammy_arm64.deb
postgresql-19-pg-kazsearch2.3.0u24.x86_64pigsty847.6 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~noble_amd64.deb
postgresql-19-pg-kazsearch2.3.0u24.aarch64pigsty796.8 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~noble_arm64.deb
postgresql-19-pg-kazsearch2.3.0u26.x86_64pigsty839.0 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~resolute_amd64.deb
postgresql-19-pg-kazsearch2.3.0u26.aarch64pigsty794.9 KiBpostgresql-19-pg-kazsearch_2.3.0-2PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_kazsearch_182.3.0el8.x86_64pigsty1.1 MiBpg_kazsearch_18-2.3.0-1PIGSTY.el8.x86_64.rpm
pg_kazsearch_182.3.0el8.aarch64pigsty1016.2 KiBpg_kazsearch_18-2.3.0-1PIGSTY.el8.aarch64.rpm
pg_kazsearch_182.3.0el9.x86_64pigsty1.1 MiBpg_kazsearch_18-2.3.0-2PGSTY.el9.x86_64.rpm
pg_kazsearch_182.3.0el9.aarch64pigsty1.1 MiBpg_kazsearch_18-2.3.0-2PGSTY.el9.aarch64.rpm
pg_kazsearch_182.3.0el10.x86_64pigsty1.1 MiBpg_kazsearch_18-2.3.0-2PGSTY.el10.x86_64.rpm
pg_kazsearch_182.3.0el10.aarch64pigsty1.1 MiBpg_kazsearch_18-2.3.0-2PGSTY.el10.aarch64.rpm
postgresql-18-pg-kazsearch2.3.0d12.x86_64pigsty762.7 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~bookworm_amd64.deb
postgresql-18-pg-kazsearch2.3.0d12.aarch64pigsty683.4 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~bookworm_arm64.deb
postgresql-18-pg-kazsearch2.3.0d13.x86_64pigsty763.7 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~trixie_amd64.deb
postgresql-18-pg-kazsearch2.3.0d13.aarch64pigsty685.6 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~trixie_arm64.deb
postgresql-18-pg-kazsearch2.3.0u22.x86_64pigsty851.4 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~jammy_amd64.deb
postgresql-18-pg-kazsearch2.3.0u22.aarch64pigsty804.9 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~jammy_arm64.deb
postgresql-18-pg-kazsearch2.3.0u24.x86_64pigsty845.7 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~noble_amd64.deb
postgresql-18-pg-kazsearch2.3.0u24.aarch64pigsty793.8 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~noble_arm64.deb
postgresql-18-pg-kazsearch2.3.0u26.x86_64pigsty837.4 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~resolute_amd64.deb
postgresql-18-pg-kazsearch2.3.0u26.aarch64pigsty790.6 KiBpostgresql-18-pg-kazsearch_2.3.0-2PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_kazsearch_172.3.0el8.x86_64pigsty1.1 MiBpg_kazsearch_17-2.3.0-1PIGSTY.el8.x86_64.rpm
pg_kazsearch_172.3.0el8.aarch64pigsty1013.8 KiBpg_kazsearch_17-2.3.0-1PIGSTY.el8.aarch64.rpm
pg_kazsearch_172.3.0el9.x86_64pigsty1.1 MiBpg_kazsearch_17-2.3.0-2PGSTY.el9.x86_64.rpm
pg_kazsearch_172.3.0el9.aarch64pigsty1.1 MiBpg_kazsearch_17-2.3.0-2PGSTY.el9.aarch64.rpm
pg_kazsearch_172.3.0el10.x86_64pigsty1.1 MiBpg_kazsearch_17-2.3.0-2PGSTY.el10.x86_64.rpm
pg_kazsearch_172.3.0el10.aarch64pigsty1.1 MiBpg_kazsearch_17-2.3.0-2PGSTY.el10.aarch64.rpm
postgresql-17-pg-kazsearch2.3.0d12.x86_64pigsty759.3 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~bookworm_amd64.deb
postgresql-17-pg-kazsearch2.3.0d12.aarch64pigsty682.8 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~bookworm_arm64.deb
postgresql-17-pg-kazsearch2.3.0d13.x86_64pigsty759.3 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~trixie_amd64.deb
postgresql-17-pg-kazsearch2.3.0d13.aarch64pigsty683.3 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~trixie_arm64.deb
postgresql-17-pg-kazsearch2.3.0u22.x86_64pigsty847.5 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~jammy_amd64.deb
postgresql-17-pg-kazsearch2.3.0u22.aarch64pigsty803.6 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~jammy_arm64.deb
postgresql-17-pg-kazsearch2.3.0u24.x86_64pigsty844.6 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~noble_amd64.deb
postgresql-17-pg-kazsearch2.3.0u24.aarch64pigsty791.2 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~noble_arm64.deb
postgresql-17-pg-kazsearch2.3.0u26.x86_64pigsty832.4 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~resolute_amd64.deb
postgresql-17-pg-kazsearch2.3.0u26.aarch64pigsty787.6 KiBpostgresql-17-pg-kazsearch_2.3.0-2PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_kazsearch_162.3.0el8.x86_64pigsty1.1 MiBpg_kazsearch_16-2.3.0-1PIGSTY.el8.x86_64.rpm
pg_kazsearch_162.3.0el8.aarch64pigsty1012.5 KiBpg_kazsearch_16-2.3.0-1PIGSTY.el8.aarch64.rpm
pg_kazsearch_162.3.0el9.x86_64pigsty1.1 MiBpg_kazsearch_16-2.3.0-2PGSTY.el9.x86_64.rpm
pg_kazsearch_162.3.0el9.aarch64pigsty1.1 MiBpg_kazsearch_16-2.3.0-2PGSTY.el9.aarch64.rpm
pg_kazsearch_162.3.0el10.x86_64pigsty1.1 MiBpg_kazsearch_16-2.3.0-2PGSTY.el10.x86_64.rpm
pg_kazsearch_162.3.0el10.aarch64pigsty1.1 MiBpg_kazsearch_16-2.3.0-2PGSTY.el10.aarch64.rpm
postgresql-16-pg-kazsearch2.3.0d12.x86_64pigsty758.1 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~bookworm_amd64.deb
postgresql-16-pg-kazsearch2.3.0d12.aarch64pigsty682.6 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~bookworm_arm64.deb
postgresql-16-pg-kazsearch2.3.0d13.x86_64pigsty758.9 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~trixie_amd64.deb
postgresql-16-pg-kazsearch2.3.0d13.aarch64pigsty682.1 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~trixie_arm64.deb
postgresql-16-pg-kazsearch2.3.0u22.x86_64pigsty847.0 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~jammy_amd64.deb
postgresql-16-pg-kazsearch2.3.0u22.aarch64pigsty802.7 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~jammy_arm64.deb
postgresql-16-pg-kazsearch2.3.0u24.x86_64pigsty844.0 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~noble_amd64.deb
postgresql-16-pg-kazsearch2.3.0u24.aarch64pigsty790.2 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~noble_arm64.deb
postgresql-16-pg-kazsearch2.3.0u26.x86_64pigsty830.6 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~resolute_amd64.deb
postgresql-16-pg-kazsearch2.3.0u26.aarch64pigsty787.2 KiBpostgresql-16-pg-kazsearch_2.3.0-2PGSTY~resolute_arm64.deb

源码

pig build pkg pg_kazsearch;		# build rpm/deb

安装

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

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

使用 pig 安装扩展。

pig install pg_kazsearch;		# install by package name

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

在数据库中创建扩展。

CREATE EXTENSION pg_kazsearch;

用法

来源:

pg_kazsearch 为 PostgreSQL 16 至 18 提供了哈萨克语全文词干提取。它安装了一个现成的 kazakh_cfg 配置和 pg_kazsearch_dict 字典。使用支持的现代拉丁字母书写法的西里尔文和哈萨克语会转换为标准的西里尔文词干,从而使文档和查询能够在不同书写系统之间匹配。

核心工作流程

CREATE EXTENSION pg_kazsearch;

SELECT ts_lexize('pg_kazsearch_dict', 'алмаларымыздағы');
-- {алма}

SELECT to_tsvector('kazakh_cfg', 'мектептеріміздегі оқушылардың');
-- 'мектеп':1 'оқушы':2

添加加权存储向量和 GIN 索引:

ALTER TABLE articles ADD COLUMN fts tsvector
GENERATED ALWAYS AS (
    setweight(to_tsvector('kazakh_cfg', title), 'A') ||
    setweight(to_tsvector('kazakh_cfg', body), 'B')
) STORED;

CREATE INDEX articles_fts_idx ON articles USING GIN (fts);

SELECT title
FROM articles
WHERE fts @@ websearch_to_tsquery('kazakh_cfg', 'президенттің жарлығы')
ORDER BY ts_rank_cd(
    fts,
    websearch_to_tsquery('kazakh_cfg', 'президенттің жарлығы')
) DESC;

字典调优

可以在运行时更改惩罚权重:

ALTER TEXT SEARCH DICTIONARY pg_kazsearch_dict
    (w_deriv = 3.5, w_short_char = 100.0);

默认的 script_mode = auto 会检测支持的现代哈萨克语拉丁字母书写法并返回西里尔文词干。当需要严格的西里尔文行为时,可以禁用拉丁字母处理:

ALTER TEXT SEARCH DICTIONARY pg_kazsearch_dict
    (script_mode = cyrillic_only);

升级和搜索注意事项

  • 在升级到 2.3.0 后,重新计算存储的 tsvector 列或重新填充触发器维护的向量,然后对表执行 VACUUM (ANALYZE)。
ALTER EXTENSION pg_kazsearch UPDATE;
UPDATE articles SET title = title;
VACUUM (ANALYZE) articles;
  • 升级前长时间运行的会话应重新连接以加载新的字典。
  • 拉丁字母支持针对现代书写法。混合书写系统的输入、过时的撇号/重音符/双字符拼写以及低置信度的 ASCII 词素可能保持不变。
  • websearch_to_tsquery 使用严格的 AND 语义处理普通词项。需要更广泛召回的应用程序应故意实现并衡量一个备选查询,而不是默默地将所有搜索都改为 OR 操作。

表格阅读器