postgresql安装pgvector 和中文的全文搜索配置

postgresql安装pgvector 和中文的全文搜索配置

pgvector

复制代码
# 1. 安装编译依赖
sudo apt-get update
sudo apt-get install -y build-essential postgresql-server-dev-15

# 2. 下载并编译 pgvector
cd /tmp
git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git
cd pgvector
make
sudo make install

中文的全文搜索

复制代码
# 1. 安装 SCWS 库
cd /tmp
wget https://github.com/hightman/scws/archive/refs/tags/1.2.3.tar.gz
tar xvf 1.2.3.tar.gz
cd scws-1.2.3
# 2. 关键步骤:生成 configure 脚本
./acprep  # 或使用 autoreconf -fiv
./configure --prefix=/usr/local
make && sudo make install

# 3. 更新动态链接库
sudo ldconfig

# 4. 安装 PostgreSQL 开发头文件(如果未安装)
sudo apt-get update
sudo apt-get install -y postgresql-server-dev-15

# 5. 编译并安装 zhparser
cd /tmp
git clone https://github.com/amutu/zhparser.git
cd zhparser

# 重要:指定 SCWS 路径
make SCWS_HOME=/usr/local
sudo make install SCWS_HOME=/usr/local

# 6. 在 PostgreSQL 中创建扩展
sudo -u postgres psql -d psql -c "
CREATE EXTENSION zhparser;
CREATE TEXT SEARCH CONFIGURATION chinese (PARSER = zhparser);
ALTER TEXT SEARCH CONFIGURATION chinese ADD MAPPING FOR n,v,a,i,e,l,j WITH simple;
"

# 7. 验证安装
sudo -u postgres psql -d psql -c "SELECT to_tsvector('chinese', '人工智能和机器学习');"
相关推荐
geovindu16 小时前
sql: Transaction & Concurrency Patterns using postgresql 18
postgresql·数据库开发·数据库架构
thinking_talk19 小时前
WorkBuddy应用生成背后的数据层:腾讯云PG
postgresql·腾讯云·云数据库
知识的搬运工旺仔2 天前
唯一索引与 NULL 值:PostgreSQL 主键约束与 NULLS NOT DISTINCT
数据库·后端·sql·postgresql
jnrjian2 天前
EDB postgresql TDE 加密的文件
postgresql
IvorySQL2 天前
PostgreSQL 日报|逻辑解码竞态条件修复(9 月 20 日)
数据库·人工智能·postgresql
XMYX-02 天前
Rocky_Linux_9.8_安装_PostgreSQL_16
postgresql
foolishlee2 天前
SCRAM-SHA-256
数据库·算法·postgresql
IvorySQL2 天前
IvorySQL 5.6 发布:PG 18.6 内核升级,沙盒即开即用
数据库·人工智能·postgresql
腾科IT教育2 天前
PGCM考试详解:认证价值、含金量及与PGCA、PGCE区别
postgresql·pg·pgcm考试·pgca考试·pgce考试
Zhu7582 天前
docker环境快速部署postgresql数据库18及以上版本
postgresql·容器