Skip to content

Commit 2be842f

Browse files
committed
support pg_jieba in IvorySQL
1 parent 700c645 commit 2be842f

4 files changed

Lines changed: 137 additions & 0 deletions

File tree

CN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
*** xref:master/ecosystem_components/zhparser.adoc[zhparser]
7777
*** xref:master/ecosystem_components/pgbackrest.adoc[pgBackRest]
7878
*** xref:master/ecosystem_components/set_user.adoc[set_user]
79+
*** xref:master/ecosystem_components/pg_jieba.adoc[pg_jieba]
7980
* 监控运维
8081
** xref:master/getting-started/daily_monitoring.adoc[日常监控]
8182
** xref:master/getting-started/daily_maintenance.adoc[日常维护]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
:sectnums:
3+
:sectnumlevels: 5
4+
5+
= pg_jieba
6+
7+
== 概述
8+
9+
pg_jieba 是PostgreSQL的一个中文分词扩展,基于著名的结巴分词(Jieba)开发。它能够将连续的中文文本切分成有意义的词语序列,为中文全文搜索提供基础支持。
10+
11+
== 功能特点
12+
13+
* *支持三种分词模式*:精确模式、全模式和搜索引擎模式。
14+
* *与PostgreSQL/IvorySQL无缝集成*
15+
* *支持自定义词典*
16+
* *支持词性标注*
17+
18+
== 安装部署
19+
20+
=== 编译安装 pg_jieba
21+
22+
假设IvorySQL已经安装在 ~/ivy_5/inst 目录中。
23+
24+
[source,shell]
25+
----
26+
git clone https://github.com/jaiminpan/pg_jieba.git
27+
cd pg_jieba
28+
git submodule update --init --recursive
29+
mkdir build;cd build
30+
cmake -DCMAKE_PREFIX_PATH=~/ivy_5/inst ..
31+
make; make install
32+
----
33+
34+
安装成功后,`pg_jieba.so` 等文件会被放置到 IvorySQL 的安装目录中。
35+
36+
=== 创建扩展并验证
37+
38+
[source,sql]
39+
----
40+
CREATE EXTENSION IF NOT EXISTS pg_jieba;
41+
SELECT name,
42+
default_version,
43+
installed_version,
44+
comment
45+
FROM pg_available_extensions
46+
WHERE name = 'pg_jieba';
47+
----
48+
49+
== 使用
50+
51+
执行如下sql示例:
52+
53+
[source,sql]
54+
----
55+
select * from to_tsquery('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
56+
to_tsquery
57+
-----------------------------------------------------------------------------------------------
58+
'拖拉机' & '学院' & '手扶拖拉机' & '专业' & '不用' & '多久' & '会' & '升职' & '加薪' & '当上' & 'ceo' & '走上' & '人生' & '巅峰'
59+
(1 row)
60+
61+
select * from to_tsvector('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
62+
to_tsvector
63+
-----------------------------------------------------------------------------------------------------
64+
'ceo':18 '不用':8 '专业':5 '人生':21 '会':13 '加薪':15 '升职':14 '多久':9 '学院':3 '巅峰':22 '当上':17 '手扶拖拉机':4 '拖拉机':2 '走上':20
65+
(1 row)
66+
----
67+
68+

EN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
*** xref:master/ecosystem_components/zhparser_en.adoc[zhparser]
7777
*** xref:master/ecosystem_components/pgbackrest.adoc[pgBackRest]
7878
*** xref:master/ecosystem_components/set_user.adoc[set_user]
79+
*** xref:master/ecosystem_components/pg_jieba.adoc[pg_jieba]
7980
* Monitor and O&M
8081
** xref:master/getting-started/daily_monitoring.adoc[Monitoring]
8182
** xref:master/getting-started/daily_maintenance.adoc[Maintenance]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
:sectnums:
3+
:sectnumlevels: 5
4+
5+
= pg_jieba
6+
7+
== Overview
8+
9+
pg_jieba is a Chinese word segmentation extension for PostgreSQL, developed based on the well-known Jieba (结巴分词) segmentation library. It can split continuous Chinese text into meaningful sequences of words, providing foundational support for Chinese full-text search.
10+
11+
== Features
12+
13+
* *Supports three segmentation modes*: precise mode, full mode, and search engine mode.
14+
* *Seamless integration with PostgreSQL/IvorySQL*
15+
* *Supports custom dictionaries*
16+
* *Supports part-of-speech tagging*
17+
18+
== Installation and Deployment
19+
20+
=== Building and Installing pg_jieba
21+
22+
Assume IvorySQL has already been installed in the `~/ivy_5/inst` directory.
23+
24+
[source,shell]
25+
----
26+
git clone https://github.com/jaiminpan/pg_jieba.git
27+
cd pg_jieba
28+
git submodule update --init --recursive
29+
mkdir build;cd build
30+
cmake -DCMAKE_PREFIX_PATH=~/ivy_5/inst ..
31+
make; make install
32+
----
33+
34+
After a successful installation, files such as `pg_jieba.so` will be placed into IvorySQL's installation directory.
35+
36+
=== Creating and Verifying the Extension
37+
38+
[source,sql]
39+
----
40+
CREATE EXTENSION IF NOT EXISTS pg_jieba;
41+
SELECT name,
42+
default_version,
43+
installed_version,
44+
comment
45+
FROM pg_available_extensions
46+
WHERE name = 'pg_jieba';
47+
----
48+
49+
== Usage
50+
51+
Run the following SQL example:
52+
53+
[source,sql]
54+
----
55+
select * from to_tsquery('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
56+
to_tsquery
57+
-----------------------------------------------------------------------------------------------
58+
'拖拉机' & '学院' & '手扶拖拉机' & '专业' & '不用' & '多久' & '会' & '升职' & '加薪' & '当上' & 'ceo' & '走上' & '人生' & '巅峰'
59+
(1 row)
60+
61+
select * from to_tsvector('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
62+
to_tsvector
63+
-----------------------------------------------------------------------------------------------------
64+
'ceo':18 '不用':8 '专业':5 '人生':21 '会':13 '加薪':15 '升职':14 '多久':9 '学院':3 '巅峰':22 '当上':17 '手扶拖拉机':4 '拖拉机':2 '走上':20
65+
(1 row)
66+
----
67+

0 commit comments

Comments
 (0)