Skip to content
Merged
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
201 changes: 101 additions & 100 deletions CN/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,100 +1,101 @@
* xref:master/about_ivorysql.adoc[关于IvorySQL]
** xref:master/welcome.adoc[欢迎]
** xref:master/release_notes.adoc[发行说明]
* 快速上手
** xref:master/getting-started/quick_start.adoc[快速开始]
* 安装部署
** xref:master/installation_guide.adoc[安装指南]
** xref:master/cluster_setup.adoc[集群搭建]
* Oracle兼容功能
** xref:master/oracle_compatibility/compat_case_conversion.adoc[1、大小写转换]
** xref:master/oracle_compatibility/compat_like_operator.adoc[2、LIKE操作符]
** xref:master/oracle_compatibility/anonymous_block.adoc[3、匿名块]
** xref:master/oracle_compatibility/compat_function_procedure.adoc[4、函数与存储过程]
** xref:master/oracle_compatibility/builtin_types_functions.adoc[5、内置数据类型与内置函数]
** xref:master/oracle_compatibility/port_ip.adoc[6、端口与IP]
** xref:master/oracle_compatibility/xml_functions.adoc[7、XML函数]
** xref:master/oracle_compatibility/sequence.adoc[8、sequence]
** xref:master/oracle_compatibility/package.adoc[9、包]
** xref:master/oracle_compatibility/invisible_column.adoc[10、不可见列]
** xref:master/oracle_compatibility/compat_rowid.adoc[11、RowID]
** xref:master/oracle_compatibility/compat_out_parameter.adoc[12、OUT 参数]
** xref:master/oracle_compatibility/compat_type_rowtype.adoc[13、%TYPE、%ROWTYPE]
** xref:master/oracle_compatibility/compat_nls_parameter.adoc[14、NLS 参数]
** xref:master/oracle_compatibility/compat_force_view.adoc[15、Force View]
** xref:master/oracle_compatibility/compat_nested_function.adoc[16、嵌套子函数]
** xref:master/oracle_compatibility/compat_sys_guid.adoc[17、sys_guid 函数]
** xref:master/oracle_compatibility/compat_empty_string_to_null.adoc[18、空字符串转null]
** xref:master/oracle_compatibility/compat_call_into.adoc[19、CALL INTO]
* 容器化与云服务
** 容器化指南
*** xref:master/containerization/k8s_deployment.adoc[K8S部署]
*** xref:master/containerization/operator_deployment.adoc[Operator部署]
*** xref:master/containerization/docker_podman_deployment.adoc[Docker & Podman部署]
*** xref:master/containerization/docker_swarm_compose_deployment.adoc[Docker Swarm & Docker Compose部署]
** 云服务平台指南
*** xref:master/cloud_platform/ivorysql_cloud_installation.adoc[IvorySQL Cloud安装]
*** xref:master/cloud_platform/ivorysql_cloud_usage.adoc[IvorySQL Cloud使用]
* IvorySQL生态
** xref:master/cpu_os_adaptation/cpu_architecture_adaptation.adoc[芯片架构适配]
** xref:master/cpu_os_adaptation/os_architecture_adaptation.adoc[操作系统适配]
** 生态组件适配
*** xref:master/ecosystem_components/ecosystem_overview.adoc[概述]
*** xref:master/ecosystem_components/postgis.adoc[postgis]
*** xref:master/ecosystem_components/pgvector.adoc[pgvector]
*** xref:master/ecosystem_components/pgddl.adoc[pgddl(DDL Extractor)]
*** xref:master/ecosystem_components/pg_cron.adoc[pg_cron]
*** xref:master/ecosystem_components/pgsql_http.adoc[pgsql-http]
*** xref:master/ecosystem_components/plpgsql_check.adoc[plpgsql_check]
*** xref:master/ecosystem_components/pgroonga.adoc[pgroonga]
*** xref:master/ecosystem_components/pgaudit.adoc[pgaudit]
*** xref:master/ecosystem_components/pgrouting.adoc[pgrouting]
*** xref:master/ecosystem_components/system_stats.adoc[system_stats]
*** xref:master/ecosystem_components/wal2json.adoc[wal2json]
*** xref:master/ecosystem_components/pg_stat_monitor.adoc[pg_stat_monitor]
*** xref:master/ecosystem_components/pg_ai_query.adoc[pg_ai_query]
*** xref:master/ecosystem_components/pg_partman.adoc[pg_partman]
*** xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer]
*** xref:master/ecosystem_components/pg_curl.adoc[pg_curl]
* 监控运维
** xref:master/getting-started/daily_monitoring.adoc[日常监控]
** xref:master/getting-started/daily_maintenance.adoc[日常维护]
** xref:master/operation_guide.adoc[运维管理指南]
* 数据迁移
** xref:master/migration_guide.adoc[迁移指南]
* IvorySQL开发者
** xref:master/contribution/community_contribution_guide.adoc[社区贡献指南]
** xref:master/developer_guide.adoc[开发者指南]
** IvorySQL架构设计
*** 查询处理
**** xref:master/architecture/dual_parser.adoc[双parser]
*** 兼容框架
**** xref:master/architecture/framework_design.adoc[框架设计]
**** xref:master/architecture/guc_framework.adoc[GUC框架]
**** xref:master/architecture/dual_mode_design.adoc[双模式设计]
**** xref:master/architecture/initdb_process.adoc[initdb过程]
*** 兼容特性
**** xref:master/compatibility_features_design/like_operator.adoc[like]
**** xref:master/compatibility_features_design/rowid.adoc[RowID]
**** xref:master/compatibility_features_design/out_parameter.adoc[OUT 参数]
**** xref:master/compatibility_features_design/type_rowtype.adoc[%TYPE、%ROWTYPE]
**** xref:master/compatibility_features_design/nls_parameter.adoc[NLS 参数]
**** xref:master/compatibility_features_design/function_procedure.adoc[函数与存储过程]
**** xref:master/compatibility_features_design/nested_function.adoc[嵌套子函数]
**** xref:master/compatibility_features_design/force_view.adoc[Force View]
**** xref:master/compatibility_features_design/case_conversion.adoc[大小写转换]
**** xref:master/compatibility_features_design/sys_guid_function.adoc[sys_guid 函数]
**** xref:master/compatibility_features_design/empty_string_to_null.adoc[空字符串转null]
**** xref:master/compatibility_features_design/call_into.adoc[CALL INTO]
*** 内置函数
**** xref:master/oracle_builtin_functions/sys_context.adoc[sys_context]
**** xref:master/oracle_builtin_functions/userenv.adoc[userenv]
*** xref:master/gb18030.adoc[国标GB18030]
* 参考指南
** xref:master/tools_reference.adoc[工具参考]
** xref:master/contribution/asciidoc_syntax_reference.adoc[asciidoc语法快速参考]
** xref:master/pg_reference/pg_parameters_reference.adoc[PG参数参考手册]
** xref:master/pg_reference/pg_functions_reference.adoc[PG函数参考手册]
* 常见问题解答
** xref:master/contribution/faq.adoc[FAQ]

* xref:master/about_ivorysql.adoc[关于IvorySQL]
** xref:master/welcome.adoc[欢迎]
** xref:master/release_notes.adoc[发行说明]
* 快速上手
** xref:master/getting-started/quick_start.adoc[快速开始]
* 安装部署
** xref:master/installation_guide.adoc[安装指南]
** xref:master/cluster_setup.adoc[集群搭建]
* Oracle兼容功能
** xref:master/oracle_compatibility/compat_case_conversion.adoc[1、大小写转换]
** xref:master/oracle_compatibility/compat_like_operator.adoc[2、LIKE操作符]
** xref:master/oracle_compatibility/anonymous_block.adoc[3、匿名块]
** xref:master/oracle_compatibility/compat_function_procedure.adoc[4、函数与存储过程]
** xref:master/oracle_compatibility/builtin_types_functions.adoc[5、内置数据类型与内置函数]
** xref:master/oracle_compatibility/port_ip.adoc[6、端口与IP]
** xref:master/oracle_compatibility/xml_functions.adoc[7、XML函数]
** xref:master/oracle_compatibility/sequence.adoc[8、sequence]
** xref:master/oracle_compatibility/package.adoc[9、包]
** xref:master/oracle_compatibility/invisible_column.adoc[10、不可见列]
** xref:master/oracle_compatibility/compat_rowid.adoc[11、RowID]
** xref:master/oracle_compatibility/compat_out_parameter.adoc[12、OUT 参数]
** xref:master/oracle_compatibility/compat_type_rowtype.adoc[13、%TYPE、%ROWTYPE]
** xref:master/oracle_compatibility/compat_nls_parameter.adoc[14、NLS 参数]
** xref:master/oracle_compatibility/compat_force_view.adoc[15、Force View]
** xref:master/oracle_compatibility/compat_nested_function.adoc[16、嵌套子函数]
** xref:master/oracle_compatibility/compat_sys_guid.adoc[17、sys_guid 函数]
** xref:master/oracle_compatibility/compat_empty_string_to_null.adoc[18、空字符串转null]
** xref:master/oracle_compatibility/compat_call_into.adoc[19、CALL INTO]
* 容器化与云服务
** 容器化指南
*** xref:master/containerization/k8s_deployment.adoc[K8S部署]
*** xref:master/containerization/operator_deployment.adoc[Operator部署]
*** xref:master/containerization/docker_podman_deployment.adoc[Docker & Podman部署]
*** xref:master/containerization/docker_swarm_compose_deployment.adoc[Docker Swarm & Docker Compose部署]
** 云服务平台指南
*** xref:master/cloud_platform/ivorysql_cloud_installation.adoc[IvorySQL Cloud安装]
*** xref:master/cloud_platform/ivorysql_cloud_usage.adoc[IvorySQL Cloud使用]
* IvorySQL生态
** xref:master/cpu_os_adaptation/cpu_architecture_adaptation.adoc[芯片架构适配]
** xref:master/cpu_os_adaptation/os_architecture_adaptation.adoc[操作系统适配]
** 生态组件适配
*** xref:master/ecosystem_components/ecosystem_overview.adoc[概述]
*** xref:master/ecosystem_components/postgis.adoc[postgis]
*** xref:master/ecosystem_components/pgvector.adoc[pgvector]
*** xref:master/ecosystem_components/pgddl.adoc[pgddl(DDL Extractor)]
*** xref:master/ecosystem_components/pg_cron.adoc[pg_cron]
*** xref:master/ecosystem_components/pgsql_http.adoc[pgsql-http]
*** xref:master/ecosystem_components/plpgsql_check.adoc[plpgsql_check]
*** xref:master/ecosystem_components/pgroonga.adoc[pgroonga]
*** xref:master/ecosystem_components/pgaudit.adoc[pgaudit]
*** xref:master/ecosystem_components/pgrouting.adoc[pgrouting]
*** xref:master/ecosystem_components/system_stats.adoc[system_stats]
*** xref:master/ecosystem_components/wal2json.adoc[wal2json]
*** xref:master/ecosystem_components/pg_stat_monitor.adoc[pg_stat_monitor]
*** xref:master/ecosystem_components/pg_ai_query.adoc[pg_ai_query]
*** xref:master/ecosystem_components/pg_partman.adoc[pg_partman]
*** xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer]
*** xref:master/ecosystem_components/pg_curl.adoc[pg_curl]
*** xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch]
* 监控运维
** xref:master/getting-started/daily_monitoring.adoc[日常监控]
** xref:master/getting-started/daily_maintenance.adoc[日常维护]
** xref:master/operation_guide.adoc[运维管理指南]
* 数据迁移
** xref:master/migration_guide.adoc[迁移指南]
* IvorySQL开发者
** xref:master/contribution/community_contribution_guide.adoc[社区贡献指南]
** xref:master/developer_guide.adoc[开发者指南]
** IvorySQL架构设计
*** 查询处理
**** xref:master/architecture/dual_parser.adoc[双parser]
*** 兼容框架
**** xref:master/architecture/framework_design.adoc[框架设计]
**** xref:master/architecture/guc_framework.adoc[GUC框架]
**** xref:master/architecture/dual_mode_design.adoc[双模式设计]
**** xref:master/architecture/initdb_process.adoc[initdb过程]
*** 兼容特性
**** xref:master/compatibility_features_design/like_operator.adoc[like]
**** xref:master/compatibility_features_design/rowid.adoc[RowID]
**** xref:master/compatibility_features_design/out_parameter.adoc[OUT 参数]
**** xref:master/compatibility_features_design/type_rowtype.adoc[%TYPE、%ROWTYPE]
**** xref:master/compatibility_features_design/nls_parameter.adoc[NLS 参数]
**** xref:master/compatibility_features_design/function_procedure.adoc[函数与存储过程]
**** xref:master/compatibility_features_design/nested_function.adoc[嵌套子函数]
**** xref:master/compatibility_features_design/force_view.adoc[Force View]
**** xref:master/compatibility_features_design/case_conversion.adoc[大小写转换]
**** xref:master/compatibility_features_design/sys_guid_function.adoc[sys_guid 函数]
**** xref:master/compatibility_features_design/empty_string_to_null.adoc[空字符串转null]
**** xref:master/compatibility_features_design/call_into.adoc[CALL INTO]
*** 内置函数
**** xref:master/oracle_builtin_functions/sys_context.adoc[sys_context]
**** xref:master/oracle_builtin_functions/userenv.adoc[userenv]
*** xref:master/gb18030.adoc[国标GB18030]
* 参考指南
** xref:master/tools_reference.adoc[工具参考]
** xref:master/contribution/asciidoc_syntax_reference.adoc[asciidoc语法快速参考]
** xref:master/pg_reference/pg_parameters_reference.adoc[PG参数参考手册]
** xref:master/pg_reference/pg_functions_reference.adoc[PG函数参考手册]
* 常见问题解答
** xref:master/contribution/faq.adoc[FAQ]

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

:sectnums:
:sectnumlevels: 5

= pg_textsearch

== 概述
pg_textsearch 是由Timescale团队开发的一个PostgreSQL扩展,旨在为Postgres提供高性能、现代化的全文搜索能力,并针对AI工作负载和混合搜索进行了优化。

== 安装

[TIP]
源码安装环境为 Ubuntu 24.04(x86_64),环境中已经安装了IvorySQL5及以上版本,安装路径为/usr/ivory-5

=== 源码安装

[literal]
----
# 从 https://github.com/timescale/pg_textsearch/archive/refs/tags/v0.6.1.tar.gz 下载源码包

tar xzvf v0.6.1.tar.gz
cd pg_textsearch-0.6.1

# 编译安装插件
make PG_CONFIG=/usr/ivory-5/bin/pg_config
make PG_CONFIG=/usr/ivory-5/bin/pg_config install

----

[TIP]
如果出现找不到xlocale.h的错误,需要手动修改 /usr/ivory-5/include/postgresql/server/pg_config.h
删除或者注释掉 #define HAVE_XLOCALE_H 1 这一行

=== 修改数据库配置文件

修改 ivorysql.conf 文件,添加 pg_textsearch 到 shared_preload_libraries

[literal]
----
shared_preload_libraries = 'gb18030_2022, liboracle_parser, ivorysql_ora, pg_textsearch'
----

重启数据库后配置生效。

=== 创建Extension

[literal]
----
postgres=# create extension pg_textsearch;
WARNING: pg_textsearch v0.6.1 is a prerelease. Do not use in production.
CREATE EXTENSION
----

== 使用

创建一个带有文本内容的表:
[literal]
----
postgres=# CREATE TABLE documents (id bigserial PRIMARY KEY, content text);
CREATE TABLE

postgres=# INSERT INTO documents (content) VALUES
('PostgreSQL is a powerful database system'),
('BM25 is an effective ranking function'),
('Full text search with custom scoring');
INSERT 0 3
----

在文本列上创建 pg_textsearch 索引:
[literal]
----
postgres=# CREATE INDEX docs_idx ON documents USING bm25(content) WITH (text_config='english');
NOTICE: BM25 index build started for relation docs_idx
NOTICE: Using text search configuration: english
NOTICE: Using index options: k1=1.20, b=0.75
NOTICE: BM25 index build completed: 3 documents, avg_length=4.33
CREATE INDEX
----

使用@操作符获取最相关的文档:
[literal]
----
postgres=# SELECT * FROM documents ORDER BY content <@> 'database system' LIMIT 5;
id | content
----+------------------------------------------
1 | PostgreSQL is a powerful database system
2 | BM25 is an effective ranking function
3 | Full text search with custom scoring
(3 rows)
----

1 change: 1 addition & 0 deletions EN/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
*** xref:master/ecosystem_components/pg_partman.adoc[pg_partman]
*** xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer]
*** xref:master/ecosystem_components/pg_curl.adoc[pg_curl]
*** xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch]
* Monitor and O&M
** xref:master/getting-started/daily_monitoring.adoc[Monitoring]
** xref:master/getting-started/daily_maintenance.adoc[Maintenance]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

:sectnums:
:sectnumlevels: 5

= pg_textsearch

== Overview
pg_textsearch is a PostgreSQL extension developed by the Timescale team. It is designed to provide high-performance, modern full-text search capabilities for Postgres, and is optimized for AI workloads and hybrid search.

== Installation

[TIP]
The source code installation environment is Ubuntu 24.04 (x86_64), in which IvorySQL 5 or a later version has been installed. The installation path is /usr/ivory-5.

=== Source Code Installation

[literal]
----
# download source code package from: https://github.com/timescale/pg_textsearch/archive/refs/tags/v0.6.1.tar.gz

tar xzvf v0.6.1.tar.gz
cd pg_textsearch-0.6.1

# compile and install the extension
make PG_CONFIG=/usr/ivory-5/bin/pg_config
make PG_CONFIG=/usr/ivory-5/bin/pg_config install
----

[TIP]
If there is error "xlocale.h: No such file or directory" during compilation, user should remove the
line of "#define HAVE_XLOCALE_H 1" from file /usr/ivory-5/include/postgresql/server/pg_config.h.

=== Modify the configuration file

Modify the ivorysql.conf file to add pg_textsearch into shared_preload_libraries.
[literal]
----
shared_preload_libraries = 'gb18030_2022, liboracle_parser, ivorysql_ora, pg_textsearch'
----

Then restart the database.

=== Create Extension

[literal]
----
postgres=# create extension pg_textsearch;
WARNING: pg_textsearch v0.6.1 is a prerelease. Do not use in production.
CREATE EXTENSION
----

== Use

Create a table with text content:
[literal]
----
postgres=# CREATE TABLE documents (id bigserial PRIMARY KEY, content text);
CREATE TABLE

postgres=# INSERT INTO documents (content) VALUES
('PostgreSQL is a powerful database system'),
('BM25 is an effective ranking function'),
('Full text search with custom scoring');
INSERT 0 3
----

Create a pg_textsearch index on the text column:
[literal]
----
postgres=# CREATE INDEX docs_idx ON documents USING bm25(content) WITH (text_config='english');
NOTICE: BM25 index build started for relation docs_idx
NOTICE: Using text search configuration: english
NOTICE: Using index options: k1=1.20, b=0.75
NOTICE: BM25 index build completed: 3 documents, avg_length=4.33
CREATE INDEX
----

Get the most relevant documents using the <@> operator:
[literal]
----
postgres=# SELECT * FROM documents ORDER BY content <@> 'database system' LIMIT 5;
id | content
----+------------------------------------------
1 | PostgreSQL is a powerful database system
2 | BM25 is an effective ranking function
3 | Full text search with custom scoring
(3 rows)
----
Loading