Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CN/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
*** xref:master/ecosystem_components/zhparser.adoc[zhparser]
*** xref:master/ecosystem_components/pgbackrest.adoc[pgBackRest]
*** xref:master/ecosystem_components/set_user.adoc[set_user]
*** xref:master/ecosystem_components/pg_jieba.adoc[pg_jieba]
* 监控运维
** xref:master/getting-started/daily_monitoring.adoc[日常监控]
** xref:master/getting-started/daily_maintenance.adoc[日常维护]
Expand Down
68 changes: 68 additions & 0 deletions CN/modules/ROOT/pages/master/ecosystem_components/pg_jieba.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

:sectnums:
:sectnumlevels: 5

= pg_jieba

== 概述

pg_jieba 是PostgreSQL的一个中文分词扩展,基于著名的结巴分词(Jieba)开发。它能够将连续的中文文本切分成有意义的词语序列,为中文全文搜索提供基础支持。

== 功能特点

* *支持三种分词模式*:精确模式、全模式和搜索引擎模式。
* *与PostgreSQL/IvorySQL无缝集成*
* *支持自定义词典*
* *支持词性标注*

== 安装部署

=== 编译安装 pg_jieba

假设IvorySQL已经安装在 ~/ivy_5/inst 目录中。

[source,shell]
----
git clone https://github.com/jaiminpan/pg_jieba.git
cd pg_jieba
git submodule update --init --recursive
mkdir build;cd build
cmake -DCMAKE_PREFIX_PATH=~/ivy_5/inst ..
make; make install
----

安装成功后,`pg_jieba.so` 等文件会被放置到 IvorySQL 的安装目录中。

=== 创建扩展并验证

[source,sql]
----
CREATE EXTENSION IF NOT EXISTS pg_jieba;
SELECT name,
default_version,
installed_version,
comment
FROM pg_available_extensions
WHERE name = 'pg_jieba';
----

== 使用

执行如下sql示例:

[source,sql]
----
select * from to_tsquery('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
to_tsquery
-----------------------------------------------------------------------------------------------
'拖拉机' & '学院' & '手扶拖拉机' & '专业' & '不用' & '多久' & '会' & '升职' & '加薪' & '当上' & 'ceo' & '走上' & '人生' & '巅峰'
(1 row)

select * from to_tsvector('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
to_tsvector
-----------------------------------------------------------------------------------------------------
'ceo':18 '不用':8 '专业':5 '人生':21 '会':13 '加薪':15 '升职':14 '多久':9 '学院':3 '巅峰':22 '当上':17 '手扶拖拉机':4 '拖拉机':2 '走上':20
(1 row)
----


1 change: 1 addition & 0 deletions EN/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
*** xref:master/ecosystem_components/zhparser_en.adoc[zhparser]
*** xref:master/ecosystem_components/pgbackrest.adoc[pgBackRest]
*** xref:master/ecosystem_components/set_user.adoc[set_user]
*** xref:master/ecosystem_components/pg_jieba.adoc[pg_jieba]
* Monitor and O&M
** xref:master/getting-started/daily_monitoring.adoc[Monitoring]
** xref:master/getting-started/daily_maintenance.adoc[Maintenance]
Expand Down
67 changes: 67 additions & 0 deletions EN/modules/ROOT/pages/master/ecosystem_components/pg_jieba.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

:sectnums:
:sectnumlevels: 5

= pg_jieba

== Overview

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.

== Features

* *Supports three segmentation modes*: precise mode, full mode, and search engine mode.
* *Seamless integration with PostgreSQL/IvorySQL*
* *Supports custom dictionaries*
* *Supports part-of-speech tagging*

== Installation and Deployment

=== Building and Installing pg_jieba

Assume IvorySQL has already been installed in the `~/ivy_5/inst` directory.

[source,shell]
----
git clone https://github.com/jaiminpan/pg_jieba.git
cd pg_jieba
git submodule update --init --recursive
mkdir build;cd build
cmake -DCMAKE_PREFIX_PATH=~/ivy_5/inst ..
make; make install
----

After a successful installation, files such as `pg_jieba.so` will be placed into IvorySQL's installation directory.

=== Creating and Verifying the Extension

[source,sql]
----
CREATE EXTENSION IF NOT EXISTS pg_jieba;
SELECT name,
default_version,
installed_version,
comment
FROM pg_available_extensions
WHERE name = 'pg_jieba';
----

== Usage

Run the following SQL example:

[source,sql]
----
select * from to_tsquery('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
to_tsquery
-----------------------------------------------------------------------------------------------
'拖拉机' & '学院' & '手扶拖拉机' & '专业' & '不用' & '多久' & '会' & '升职' & '加薪' & '当上' & 'ceo' & '走上' & '人生' & '巅峰'
(1 row)

select * from to_tsvector('jiebacfg', '是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。');
to_tsvector
-----------------------------------------------------------------------------------------------------
'ceo':18 '不用':8 '专业':5 '人生':21 '会':13 '加薪':15 '升职':14 '多久':9 '学院':3 '巅峰':22 '当上':17 '手扶拖拉机':4 '拖拉机':2 '走上':20
(1 row)
----

Loading