Skip to content

Commit 8878b4f

Browse files
authored
Merge pull request #183 from OreoYang/pgroonga
add pgroonga adaption docs
2 parents dbb97b1 + 45782a4 commit 8878b4f

File tree

10 files changed

+196
-7
lines changed

10 files changed

+196
-7
lines changed

CN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*** xref:master/5.4.adoc[pg_cron]
2020
*** xref:master/5.5.adoc[pgsql-http]
2121
*** xref:master/5.6.adoc[plpgsql_check]
22+
*** xref:master/5.7.adoc[pgroonga]
2223
** IvorySQL架构设计
2324
*** 查询处理
2425
**** xref:master/6.1.1.adoc[双parser]

CN/modules/ROOT/pages/master/5.0.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ IvorySQL 作为一款兼容 Oracle 且基于 PostgreSQL 的高级开源数据库
1717
| xref:master/5.4.adoc[pg_cron]​ | 1.6.0 | 提供数据库内部的定时任务调度功能,支持定期执行SQL语句 | 数据清理、定期统计、自动化维护任务
1818
| xref:master/5.5.adoc[pgsql-http]​ | 1.7.0 | 允许在SQL中发起HTTP请求,与外部Web服务进行交互 | 数据采集、API集成、微服务调用
1919
| xref:master/5.6.adoc[plpgsql_check] | 2.8 | 提供PL/pgSQL代码的静态分析功能,可在开发阶段发现潜在错误 | 存储过程开发、代码质量检查、调试优化
20+
| xref:master/5.7.adoc[pgroonga] | 4.0.4 | 提供​非英语语言全文搜索功能,满足高性能应用的需求 | 中日韩等语言的全文搜索功能
2021
|====
2122

2223
这些插件均经过 IvorySQL 团队的测试和适配,确保在 IvorySQL 环境下稳定运行。用户可以根据业务需求选择合适的插件,进一步提升数据库系统的能力和灵活性。
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
:sectnums:
3+
:sectnumlevels: 5
4+
5+
= PGroonga
6+
7+
== 概述
8+
PostgreSQL 内置了全文搜索功能,但在处理​​大规模数据​​、​​复杂查询​​以及​​非英语语言(特别是中日韩等 CJK 语言)​​ 时,其功能和性能可能无法满足高性能应用的需求。
9+
10+
PGroonga 应运而生,它是一个 PostgreSQL 的扩展插件,将 ​​Groonga​​ 这款高性能的全功能全文搜索引擎与 PostgreSQL 数据库深度融合。Groonga 本身是一个优秀的开源搜索引擎,以其极致的速度和丰富的功能著称,尤其擅长处理多语言文本。PGroonga 的使命就是将 Groonga 的强大能力无缝地带入 PostgreSQL 的世界,为用户提供远超原生全文搜索的体验。
11+
12+
== 安装
13+
[NOTE]
14+
IvorySQL的安装包里已经集成了PGroonga插件,如果使用安装包安装的IvorySQL,通常不需要再手动安装PGroonga,直接跳过安装步骤即可。
15+
16+
用户可从 https://pgroonga.github.io/install[PGroonga package安装] 页面选择适合自己的方式进行PGroonga安装。
17+
18+
IvorySQL社区提供了源码安装步骤,下面以PGroonga v4.0.4为例进行演示。
19+
20+
=== 安装依赖
21+
22+
环境
23+
```
24+
操作系统:Ubuntu 24.04
25+
CPU架构:x86_64
26+
IvorySQL: v5.0
27+
```
28+
29+
==== 安装 msgpack-c
30+
31+
编译PGroonga,有个配置选项:HAVE_MSGPACK=1,它是用于支持WAL,使用这个选项需要安装msgpack-c 1.4.1或者更高版本。
32+
33+
```
34+
sudo apt install libmsgpack-dev
35+
```
36+
==== 安装 Groonga
37+
38+
确保Groonga >= 14.0.0
39+
40+
```
41+
sudo apt install groonga libgroonga-dev
42+
```
43+
验证Groonga安装成功
44+
```bash
45+
highgo@ubuntu:~/work/IvorySQL/inst$ groonga --version
46+
Groonga 15.1.7 [Linux,x86_64,utf8,match-escalation-threshold=0,nfkc,mecab,message-pack,mruby,onigmo,zlib,lz4,zstandard,epoll,apache-arrow,xxhash,blosc,h3,simdjson,llama.cpp]
47+
```
48+
49+
50+
=== 编译安装PGroonga
51+
52+
==== 下载解压源码
53+
54+
```bash
55+
wget https://packages.groonga.org/source/pgroonga/pgroonga-4.0.4.tar.gz
56+
tar xvf pgroonga-4.0.4.tar.gz
57+
cd pgroonga-4.0.4
58+
```
59+
==== 编译
60+
运行make前确保`pg_config`命令的路径在`PATH`环境变量里,例如IvorySQL安装的路径是`~/work/IvorySQL/inst`,则环境变量设置如下:
61+
62+
```bash
63+
export PGHOME=~/work/IvorySQL/inst
64+
export PGDATA=$PGHOME/data
65+
export PATH=$PGHOME/bin:$PATH
66+
```
67+
然后执行以下命令进行编译和安装:
68+
```bash
69+
make HAVE_MSGPACK=1
70+
make install
71+
```
72+
73+
== 创建Extension并确认PGroonga版本
74+
75+
76+
psql 连接到数据库的pg模式下,执行命令:
77+
```sql
78+
postgres=# CREATE extension pgroonga;
79+
CREATE EXTENSION
80+
postgres=# SELECT * FROM pg_available_extensions WHERE name = 'pgroonga';
81+
name | default_version | installed_version | comment
82+
----------+-----------------+-------------------+--------------------------------------------------------------------------------
83+
pgroonga | 4.0.4 | 4.0.4 | Super fast and all languages supported full text search index based on Groonga
84+
(1 row)
85+
86+
postgres=# select version();
87+
version
88+
--------------------------------------------------------------------------------
89+
PostgreSQL (IvorySQL 5.0) 18.0 on x86_64-linux, compiled by gcc-13.3.0, 64-bit
90+
(1 row)
91+
```
92+
93+
== 使用
94+
关于PGroonga的使用,请参阅 https://pgroonga.github.io/tutorial[PGroonga官方文档]

CN/modules/ROOT/pages/master/6.4.1.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
= **功能概述**
77

8-
IvorySQL提供兼容Oracle内置函数`SYS_CONTEXT('namespace', 'parameter' [, length ])`,
8+
IvorySQL提供兼容Oracle内置函数 ```SYS_CONTEXT('namespace', 'parameter' [, length ])``` ,
99
返回当前时刻与给定上下文关联参数的值,可以在SQL和PLSQL语言中使用。
1010

1111
提供以下命名空间:
@@ -16,8 +16,8 @@ IvorySQL提供兼容Oracle内置函数`SYS_CONTEXT('namespace', 'parameter' [, l
1616

1717
== 实现原理
1818

19-
SYS_CONTEXT的实现原理是通过动态查询系统表与postgres的内置函数,确保结果的实时性,
20-
使用 SECURITY INVOKER 确保函数以调用者的权限执行,避免权限提升问题。
19+
`SYS_CONTEXT` 的实现原理是通过动态查询系统表与postgres的内置函数,确保结果的实时性,
20+
使用 `SECURITY INVOKER` 确保函数以调用者的权限执行,避免权限提升问题。
2121
该方法的实现逻辑如下:
2222
```sql
2323
CREATE OR REPLACE FUNCTION sys.sys_context(a varchar2, b varchar2)

CN/modules/ROOT/pages/master/6.4.2.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
= **功能概述**
77

8-
IvorySQL提供兼容Oracle内置函数`USERENV('parameter')`,用于返回当前会话的相关信息。
9-
这是一个遗留函数,建议使用 SYS_CONTEXT 函数及其内置的 USERENV 命名空间来获取当前功能。
8+
IvorySQL提供兼容Oracle内置函数 ```USERENV('parameter')``` ,用于返回当前会话的相关信息。
9+
这是一个遗留函数,建议使用 `SYS_CONTEXT` 函数及其内置的 `USERENV` 命名空间来获取当前功能。
1010

1111
== 实现原理
1212

EN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
** xref:master/5.4.adoc[pg_cron]
1919
** xref:master/5.5.adoc[pgsql-http]
2020
** xref:master/5.6.adoc[plpgsql_check]
21+
** xref:master/5.7.adoc[pgroonga]
2122
* IvorySQL Architecture Design
2223
** Query Processing
2324
*** xref:master/6.1.1.adoc[Dual Parser]

EN/modules/ROOT/pages/master/5.0.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ IvorySQL, as an advanced open-source database compatible with Oracle and based o
1717
| xref:master/5.4.adoc[pg_cron]​ | 1.6.0 | Provides database-internal scheduled task scheduling functionality, supports regular SQL statement execution | Data cleanup, regular statistics, automated maintenance tasks
1818
| xref:master/5.5.adoc[pgsql-http]​ | 1.7.0 | Allows HTTP requests to be initiated in SQL, interacting with external web services | Data collection, API integration, microservice calls
1919
| xref:master/5.6.adoc[plpgsql_check] | 2.8 | Provides static analysis functionality for PL/pgSQL code, can detect potential errors during development | Stored procedure development, code quality checking, debugging and optimization
20+
| xref:master/5.7.adoc[pgroonga] | 4.0.4 | Provides full-text search functionality for non-English languages, meeting the needs of high-performance applications | Full-text search capabilities for languages like Chinese, Japanese, and Korean
2021
|====
2122

2223
These plugins have all been tested and adapted by the IvorySQL team to ensure stable operation in the IvorySQL environment. Users can select appropriate plugins based on business needs to further enhance the capabilities and flexibility of the database system.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
= PGroonga
5+
6+
== Overview
7+
PostgreSQL has built-in full-text search functionality, but when dealing with large-scale data, complex queries, and non-English languages (especially CJK languages like Chinese, Japanese, and Korean), its functionality and performance may not meet the requirements of high-performance applications.
8+
9+
PGroonga was created to address this need. It is a PostgreSQL extension that deeply integrates Groonga, a high-performance full-featured full-text search engine, with the PostgreSQL database. Groonga itself is an excellent open-source search engine, renowned for its extreme speed and rich functionality, particularly excelling at handling multilingual text. PGroonga's mission is to seamlessly bring Groonga's powerful capabilities into the PostgreSQL world, providing users with an experience that far exceeds native full-text search.
10+
11+
== Installation
12+
[NOTE]
13+
The PGroonga plugin is already included in the IvorySQL installation package. If you installed IvorySQL using the official released package, you typically do not need to manually install PGroonga and can skip the installation steps.
14+
15+
You can choose their preferred installation method for PGroonga from the https://pgroonga.github.io/install[PGroonga package installation] page.
16+
17+
The IvorySQL community provides source code installation steps, demonstrated below using PGroonga v4.0.4 as an example.
18+
19+
=== Dependencies
20+
21+
Setup Environment
22+
```
23+
Operating System: Ubuntu 24.04
24+
CPU Architecture: x86_64
25+
IvorySQL: v5.0
26+
```
27+
==== Install msgpack-c
28+
29+
When compile PGroonga, there is an option: `HAVE_MSGPACK=1`, which is used to support WAL. Enabling this option requires installing msgpack-c 1.4.1 or newer version.
30+
```bash
31+
sudo apt install libmsgpack-dev
32+
```
33+
==== Install Groonga
34+
35+
Ensure Groonga >= 14.0.0 is installed.
36+
```bash
37+
sudo apt install groonga libgroonga-dev
38+
```
39+
Verify Groonga installation:
40+
41+
```bash
42+
highgo@ubuntu:~/work/IvorySQL/inst$ groonga --version
43+
Groonga 15.1.7 [Linux,x86_64,utf8,match-escalation-threshold=0,nfkc,mecab,message-pack,mruby,onigmo,zlib,lz4,zstandard,epoll,apache-arrow,xxhash,blosc,h3,simdjson,llama.cpp]
44+
```
45+
46+
=== Compile and Install PGroonga
47+
48+
==== Download and Extract the PGroonga Source Code
49+
50+
```bash
51+
wget https://packages.groonga.org/source/pgroonga/pgroonga-4.0.4.tar.gz
52+
tar xvf pgroonga-4.0.4.tar.gz
53+
cd pgroonga-4.0.4
54+
```
55+
==== Compile
56+
57+
Before running make , ensure that the `pg_config` command is in the `PATH` environment variable. For example, if IvorySQL is installed at `~/work/IvorySQL/inst` , set the environment variables as follows:
58+
59+
```bash
60+
export PGHOME=~/work/IvorySQL/inst
61+
export PGDATA=$PGHOME/data
62+
export PATH=$PGHOME/bin:$PATH
63+
```
64+
Then execute the following commands to compile and install:
65+
66+
```bash
67+
make HAVE_MSGPACK=1
68+
make install
69+
```
70+
71+
== Create Extension PGroonga and Confirm the version
72+
73+
Connect to the database with `psql` in `pg` mode and execute the following commands:
74+
```sql
75+
postgres=# CREATE extension pgroonga;
76+
CREATE EXTENSION
77+
postgres=# SELECT * FROM pg_available_extensions WHERE name = 'pgroonga';
78+
name | default_version | installed_version | comment
79+
----------+-----------------+-------------------+--------------------------------------------------------------------------------
80+
pgroonga | 4.0.4 | 4.0.4 | Super fast and all languages supported full text search index based on Groonga
81+
(1 row)
82+
83+
postgres=# select version();
84+
version
85+
--------------------------------------------------------------------------------
86+
PostgreSQL (IvorySQL 5.0) 18.0 on x86_64-linux, compiled by gcc-13.3.0, 64-bit
87+
(1 row)
88+
```
89+
90+
== Usage
91+
For PGroonga usage, please refer to the https://pgroonga.github.io/tutorial[PGroonga Official Documentation]

EN/modules/ROOT/pages/master/6.4.1.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
= **Feature Overview**
55

6-
IvorySQL provides compatibility with the Oracle built-in function `SYS_CONTEXT('namespace', 'parameter' [, length ])`,
6+
IvorySQL provides compatibility with the Oracle built-in function ```SYS_CONTEXT('namespace', 'parameter' [, length ])```,
77
which returns the value of the parameter associated with the given context at the current moment. It can be used in both SQL and PL/SQL languages.
88

99
IvorySQL provides the following built-in namespaces:

EN/modules/ROOT/pages/master/6.4.2.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
= **Feature Overview**
55

6-
IvorySQL provides compatibility with Oracle's built-in function `USERENV('parameter')`, which is used to return information about the current session.
6+
IvorySQL provides compatibility with Oracle's built-in function ```USERENV('parameter')```, which is used to return information about the current session.
77
This is a legacy function, and IvorySQL recommends taht you can use the `SYS_CONTEXT` function with its built-in `USERENV` namespace for current functionality.
88

99
== Implementation Principle

0 commit comments

Comments
 (0)