轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像
交易
充值流量¥8起我的订单
文档
工具
提交工单页面收录
zhparser

abcfy2/zhparser

abcfy2

基于zhparser的PostgreSQL中文全文搜索Docker镜像,支持中文分词与全文检索,基于PostgreSQL官方镜像构建,提供多版本及Alpine基础镜像支持。

11 次收藏下载次数: 0状态:社区镜像维护者:abcfy2仓库类型:镜像最近更新:1 个月前
让 AI 帮你使用轩辕镜像? · 展开查看说明 · 点击收起说明

如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。

只需在 AI 对话中先发送下面这段话即可:

请先阅读并遵守:https://xuanyuan.cloud/agents.md

未读文档前不要生成 pull 命令或排错方案。

查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。

DockerHub 官方简介
轩辕镜像中文简介
下载命令
镜像标签列表与下载命令
轩辕镜像,加速的不只是镜像。
点击查看

https://hub.docker.com/r/abcfy2/zhparser | https://github.com/abcfy2/docker_zhparser/pkgs/container/zhparser | https://quay.io/repository/abcfy2/zhparser

A source repo of Postgres Chinese full-test search docker image, based on zhparser.

Fork from: https://github.com/chen-xin/docker_zhparser, and upgrade to new version.

Supported tags and respective Dockerfile links

  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.debian
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.debian
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.debian
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.debian
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.debian
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.debian
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.alpine
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.alpine
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.alpine
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.alpine
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.alpine
  • https://github.com/abcfy2/docker_zhparser/blob/main/Dockerfile.alpine

The numbers above are postgres docker image versions.

Quick reference

Until version 9, Chinese full-text search is not shipped with PostgreSQL official release, and has to be implement by third-party extensions.

Zhparser, based on Xunsearch's Simple Chinese Word Segmentation(SCWS), appears to be most frequent in google results of "Chinese full-text postgres", and still actively mantained recently.

https://github.com/amutu/zhparser "zhparser on Github" xunsearch dict attr descriptions https://github.com/aboutstudy/scel2mmseg"sougou dict convert to text"

How to use this image

To run this image, please refer to the https://store.docker.com/images/postgres. A basic command would be docker run -p 5432:5432 chenxinaz/zhparser.

When the container runs first time, the follow scripts would be executed on the default database. You need to run them to configure zhparser for any other newly created databases :

sql
CREATE EXTENSION zhparser;
CREATE TEXT SEARCH CONFIGURATION chinese_zh (PARSER = zhparser);
ALTER TEXT SEARCH CONFIGURATION chinese_zh ADD MAPPING FOR n,v,a,i,e,l WITH simple;

config descriptions:

  • "chinese_zh" is a custom name, change to what you like.
  • "n,v,a,i,e,l,t" is the token types, unmapped token types would not be used for document tockenize. Use \dFp+ zhparser to list all token types zhparser populates.

Testing

ts_debug:

select ts_debug('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');

txt
ts_debug
-------------------------------------------
(t,time,白垩纪,{},,)
(v,verb,是,{simple},simple,{是})
(n,noun,地球,{simple},simple,{地球})
(n,noun,上海,{simple},simple,{上海})
(m,numeral,陆,{},,)
(v,verb,分布,{simple},simple,{分布})
(c,conjunction,和,{},,)
(n,noun,生物界,{simple},simple,{生物界})
(d,adverb,急剧,{},,)
(v,verb,变化,{simple},simple,{变化})
(u,auxiliary,、,{},,)
(n,noun,火山,{simple},simple,{火山})
(v,verb,活动,{simple},simple,{活动})
(a,adjective,频繁,{simple},simple,{频繁})
(u,auxiliary,的,{},,)
(n,noun,时代,{simple},simple,{时代})
(16 rows)

We can see the parser make some mistakes:"海陆" is not identified as a single word. Another portential problem is that "白垩纪" was identified as "t,time", which not included in zhparser official document's sample mapping setting(only 'n,v,a,i,e,l' ), this make newbees confused as it is not tokenized.

to_tsvector:

select to_tsvector('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');

txt
to_tsvector
--------------------------------------------------------------------------------------------
'上海':3 '分布':4 '变化':6 '地球':2 '时代':10 '是':1 '活动':8 '火山':7 '生物界':5 '频繁':9
(1 row)

We can see "白垩纪" is not in the result. To include it, we need ALTER TEXT SEARCH CONFIGURATION chinese_zh ADD MAPPING FOR t WITH simple;

to_tsquery & plainto_tsquery

sql
select to_tsquery('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
select plainto_tsquery('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
select to_tsquery('chinese_zh', '白垩纪 是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
select plainto_tsquery('chinese_zh', '白垩纪 是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
txt
                                       to_tsquery
-----------------------------------------------------------------------------------------
 '是' & '地球' & '上海' & '分布' & '生物界' & '变化' & '火山' & '活动' & '频繁' & '时代'
(1 row)

All above querys products same result excepts the 3rd throws syntax error. You can try the queries without 'chinese_zh' argument to see what happens.

combine query & vector

sql
select to_tsquery('地球') @@ to_tsvector('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
select to_tsquery('chinese_zh', '地球') @@ to_tsvector('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
txt
?column?
.----------
t
(1 row)
select
select to_tsquery('chinese_zh', '地球上') @@ to_tsvector('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
txt
>?column?
.----------
f
(1 row)

This result is unexpected, even blind can see with his nose that '地球上' is definatly inside '白垩纪是地球上海陆分布..', why false? Let's dive a little deeper:

sql
select to_tsquery('地球上');
select to_tsquery('chinese_zh', '地球上');
select to_tsvector('白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
select to_tsvector('chinese_zh', '白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
select ts_debug('chinese_zh', '地球上');
select to_tsvector('chinese_zh', '海陆');
txt
'地球上'
'地球' & '上'
'火山活动频繁的时代':2 '白垩纪是地球上海陆分布和生物界急剧变化':1
'上海':3 '分布':4 '变化':6 '地球':2 '时代':10 '是':1 '活动':8 '火山':7 '生物界':5 '频繁':9
 (n,noun,地球,{simple},simple,{地球})
 (v,verb,上,{simple},simple,{上})
'海陆':1

Now we can see that the ts_query '地球' & '上' would not math the ts_vector '上海':3 '分布':4 '变化':6 '地球':2 '时代':10 '是':1 '活动':8 '火山':7 '生物界':5 '频繁':9.

Supposed soluctions are:

  • Make '地球上' a token with higher priority than '上海'(bad idea);
  • Make '海陆' a token with higher priority than '上海';
  1. Use in table and querys

Note: I have added my custom dict for words '白垩纪' and '达纳苏斯', see next chapter for detail.

sql
-- you may need run the next line first, I haven't tested yet
-- CREATE EXTENSION pg_trgm;

create table testing(
  title text
  );

insert into testing values('白垩纪是地球上海陆分布和生物界急剧变化、火山活动频繁的时代');
insert into testing values('艾泽拉斯包括卡利姆多、东部王国两大大陆,暗夜精灵主城达纳苏斯位于东部王国北端。');
create index ind_testing on testing using gin (to_tsvector('chinese_zh', title));

select * from testing where to_tsquery('chinese_zh', '白垩纪') @@ to_tsvector('chinese_zh', title);
select * from testing where to_tsquery('chinese_zh', '达纳苏斯') @@ to_tsvector('chinese_zh', title);

explain select * from testing where to_tsquery('chinese_zh', '达纳苏斯') @@ to_tsvector('chinese_zh', title);

You may confused why the last statement shows that the query is using sequence scan instead of index scan, there may be 2 reasons:

  1. Query string is too short, that postgres thinks it matches too much rows and not worthy using index;
  2. Rows in table is few and hardly benifit from indexing.

In my test of 100,000 rows table, the result is :

txt
Bitmap Heap Scan on doc_pack  (cost=23.88..1658.13 rows=500 width=1448) (actual time=18.410..18.411 rows=1 loops=1)
  Recheck Cond: ('''达纳苏斯'''::tsquery @@ to_tsvector('chinese_zh'::regconfig, (title)::text))
  Heap Blocks: exact=1
  ->  Bitmap Index Scan on ind_doc_pack_title  (cost=0.00..23.75 rows=500 width=0) (actual time=18.402..18.402 rows=1 loops=1)
        Index Cond: ('''达纳苏斯'''::tsquery @@ to_tsvector('chinese_zh'::regconfig, (title)::text))
Planning time: 0.103 ms
Execution time: 18.440 ms

Another test of 2,700,000 rows table, the result is :

txt
Bitmap Heap Scan on docs  (cost=47.12..11533.37 rows=2983 width=2844) (actual time=25.364..25.365 rows=1 loops=1)
   Recheck Cond: ('''达纳苏斯'''::tsquery @@ to_tsvector('chinese_zh'::regconfig, (title)::text))
   Heap Blocks: exact=1
   ->  Bitmap Index Scan on ind_doc_title  (cost=0.00..46.37 rows=2983 width=0) (actual time=25.355..25.355 rows=1 loops=1)
         Index Cond: ('''达纳苏斯'''::tsquery @@ to_tsvector('chinese_zh'::regconfig, (title)::text))
 Planning time: 19.188 ms
 Execution time: 25.392 ms
sql
insert into doc_pack(id, title, no, doc_keeper, archive_type, speciaty)
values ('asdf', '艾泽拉斯包括卡利姆多、东部王国两大大陆,暗夜精灵主城达纳苏斯位于东部王国北端。', 'b1234', 'aa', 'bb', 'cc');

explain analyze select * from doc_pack where to_tsquery('chinese_zh', '达纳苏斯') @@ to_tsvector('chinese_zh', title);

insert into docs(id, file_type, create_time, title, size, uri)
values ('asdf', 'aaa', now(), '艾泽拉斯包括卡利姆多、东部王国两大大陆,暗夜精灵主城达纳苏斯位于东部王国北端。', 0, '');

explain analyze select * from docs where to_tsquery('chinese_zh', '达纳苏斯') @@ to_tsvector('chinese_zh', title);
  1. Add customer dicts(txt)

First test some custom words with current configure:

sql
select ts_debug('chinese_zh', '艾泽拉斯');
select ts_debug('chinese_zh', '卡利姆多');
select ts_debug('chinese_zh', '达纳苏斯');
select ts_debug('chinese_zh', '遗忘海岸');
select ts_debug('chinese_zh', '艾萨拉');
txt
 (n,noun,艾泽,{simple},simple,{艾泽})
 (n,noun,拉斯,{simple},simple,{拉斯})

 (n,noun,泰达,{simple},simple,{泰达})
 (n,noun,希尔,{simple},simple,{希尔})

 (v,verb,遗忘,{simple},simple,{遗忘})
 (s,space,海岸,{},,)

 (n,noun,艾萨,{simple},simple,{艾萨})
 (v,verb,拉,{simple},simple,{拉})

Create the customer dict in /usr/share/postgresql/9.6/tsearch_data/mydict.utf8.txt:(you can user other name you like, but must in that very dir)

txt
#word TF  IDF ATTR
艾泽拉斯  1 1 n
卡利姆多  1 1 n
泰达希尔  1 1 n
达纳苏斯  1 1 n
多兰纳尔  1 1 n
艾萨拉  1 1 n
遗忘海岸  1 1 n

Note: What if dict encoding different from database? Note: According to zhparser document, the TF, IDF, ATTR can be ommited in dict file. If you do omitted, rember to ALTER TEXT SEARCH CONFIGURATION chinese_zh ADD MAPPING FOR x WITH simple;, or the new wods woun't be used in to_tsvector, hence you can't search for them in query.

Then modify /var/lib/postgresql/data/posrgresql.conf, append following line at the end : zhparser.extra_dicts = 'mydict.utf8.txt'

If you use my docker image azurewind.psqlcnft, There is no vi or nano etc in default docker container, you can modify the file with: echo "zhparser.extra_dicts = 'mydict.utf8.txt'" >> /var/lib/postgresql/data/postgresql.conf.

Now restart postgres, and test again:

sql
select ts_debug('chinese_zh', '艾泽拉斯');
select ts_debug('chinese_zh', '卡利姆多');
select ts_debug('chinese_zh', '达纳苏斯');
select ts_debug('chinese_zh', '遗忘海岸');
select ts_debug('chinese_zh', '艾萨拉');
sql
(n,noun,艾泽拉斯,{simple},simple,{艾泽拉斯})
(n,noun,卡利姆多,{simple},simple,{卡利姆多})
(n,noun,达纳苏斯,{simple},simple,{达纳苏斯})
(n,noun,遗忘海岸,{simple},simple,{遗忘海岸})
(n,noun,艾萨拉,{simple},simple,{艾萨拉})
  1. Add customer dicts(xdb)

According to the zhparser document, xdb format dict is preferred to txt format. Here is the steps(run in bash):

sh
# suppose you have already created mydict.utf8.txt in this directory:
cd /usr/share/postgresql/9.6/tsearch_data
# In my docker container, without running this causes lib not found error
ldconfig
# Generate xdb dict from txt as scws document
scws-gen-dict -c UTF8 mydict.utf8.txt mydict.utf8.xdb
# In my testing, root owned xdb dict not accessable to postgresql
chown postgres:postgres mydict.utf8.xdb
# update configure
sed -i 's/mydict\.utf8\.txt/mydict.utf8.xdb/' /var/lib/postgresql/data/postgresql.conf
# verfy configure
tail /var/lib/postgresql/data/postgresql.conf

Restart Postgres and test as above.

  1. additional resources

Found a scel2mmseg tool: https://github.com/aboutstudy/scel2mmseg"sougou dict convert to text"

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 zhparser 镜像标签

docker pull docker.xuanyuan.run/abcfy2/zhparser:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull abcfy2/zhparser:<标签>

轩辕镜像配置手册

按平台快速找到配置文档

一键安装

一键安装 Docker

Linux Docker 一键安装

AI

用 AI 使用轩辕镜像

agents.md · AI 对话 · 提示词

Docker

登录仓库拉取

登录认证 · 私有仓库

专属域名拉取

免登录 · 高速拉取

Linux

Docker 镜像配置

Windows / Mac

Docker Desktop 配置

MacOS OrbStack

OrbStack 容器

Apple Container

macOS 原生容器

Docker Compose

Compose 项目配置

NAS

群晖

Synology 配置

飞牛

fnOS 镜像配置

绿联

绿联 NAS

威联通

QNAP 配置

极空间

极空间 NAS

Unraid

Unraid NAS

企业仓库

其他仓库

ghcr · Quay · nvcr

Harbor 镜像源

Proxy Repository 对接

Portainer 镜像源

Registries 配置

Nexus 镜像源

Docker Proxy 缓存

开发工具

Dev Containers

VS Code 开发容器

Podman

Podman 配置指南

Singularity / Apptainer

HPC 科学计算容器

Kubernetes

K8s Containerd

Kubernetes · Containerd

K3s

轻量级集群

面板 / 网络

爱快路由

爱快 4.0 · iKuai 镜像加速

宝塔面板

一键配置镜像源

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

功能

版本功能对比

功能对比 · 版本选择

支持的镜像仓库

Docker Hub · GCR · GHCR

专属域名用法

专属域名 · 开启停用 · 多仓库

新手拉取配置

登录 · 专属域名 · 配置

docker search 限制

专属域名 · Hub 搜索

不支持 push

仅支持 pull · 不支持

拉取速度原因

带宽 · 缓存 · 冷热镜像

错误码

402 与流量用尽

402 · 流量包 · 充值

401 认证失败

401 · docker login

manifest unknown

标签错误 · 镜像不存在

410 Gone 排查

410 · Docker 升级

429 限流

免费版 · 专业版 · 企业版 · 请求频率

其他报错

DNS 超时

DNS 解析 · 网络超时

TLS 证书失败

no matching manifest(架构)

docker.sock / daemon

账号

失败是否计费

manifest · blob · 计费

申请开票(企业 / 个人)

开票 · 发票 · 工单

修改登录密码

网站 · 仓库 · 重置

注销账户

工单 · 数据 · 注销

原理

mirrors 不生效

daemon.json · 重启

去掉域名前缀

docker tag · 重命名

指定架构拉取

ARM64 · AMD64 · 多架构

latest 与「最新」

digest · 版本号 · 标签

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
abcfy2/zhparser
定价查看流量套餐与价格
博客Docker 镜像公告与技术博客
官方技术交流群:|问题咨询请:提交工单
服务号:轩辕镜像|公众号:源码跳动|小程序:轩辕镜像|官方技术交流群:|问题咨询请:提交工单
专业版 · 高速稳定拉取镜像
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
50GB 仅 ¥8/年
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
用户协议·隐私政策·增值电信业务经营许可证:浙B2-20261007·©2024-2026 源码跳动©2024-2026 杭州源码跳动科技有限公司·商务合作:点击复制邮箱

更多相关 Docker 镜像与资源

以下是 abcfy2/zhparser 相关的常用 Docker 镜像,适用于 不同场景 等不同场景:

  • zhparser/zhparser Docker 镜像说明(Zhparser 容器镜像,适合 zhparser 维护的 Zhparser 工作负载部署)

更多 zhparser 镜像推荐

zhparser/zhparser logo

zhparser/zhparser

zhparser
zhparser是一个用于中文全文搜索的PostgreSQL扩展。
2 次收藏9千+ 次下载
2 年前更新
chenxinaz/zhparser logo

chenxinaz/zhparser

chenxinaz
基于zhparser的PostgreSQL中文全文检索Docker镜像,提供中文分词和全文搜索功能,支持自定义词典,适用于需要中文全文检索的PostgreSQL应用场景。
7 次收藏1万+ 次下载
8 年前更新
symbolspace/zhparser logo

symbolspace/zhparser

symbolspace
基于PostGIS的PostgreSQL镜像,集成zhparser扩展以实现中文全文搜索功能。
1 次收藏1.5千+ 次下载
5 年前更新
lightrabbit/zhparser logo

lightrabbit/zhparser

lightrabbit
基于zhparser的PostgreSQL中文全文搜索扩展镜像,支持中文分词与全文检索功能,适用于需在PostgreSQL中实现中文内容搜索的场景。
83 次下载
6 年前更新
mixdeve/postgres-zhparser logo

mixdeve/postgres-zhparser

mixdeve
包含zhparser插件的PostgreSQL Docker镜像,支持中文全文搜索,预安装插件无需手动编译,开箱即用中文分词功能,适用于需要中文文本检索的PostgreSQL应用场景。
2 次收藏5万+ 次下载
1 个月前更新

查看更多 zhparser 相关镜像