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', '人工智能和机器学习');"
相关推荐
阿里小阿希7 小时前
CentOS7 PostgreSQL 9.2 升级到 15 完整教程
数据库·postgresql
WangJunXiang68 小时前
第09章:PostgreSQL日常维护
数据库·postgresql
dyyshb11 小时前
PostgreSQL 终极兜底方案
数据库·postgresql
Mr.徐大人ゞ14 小时前
2-5.全文索引与并行查询
postgresql
360智汇云14 小时前
PostgreSQL 全文检索深度指南:内置 FTS、zhparser 与 pg_search 全解
postgresql·django·全文检索
有想法的py工程师15 小时前
PostgreSQL 性能优化实战:一条 Order by 的 SQL 从 5 秒优化到 100ms
大数据·数据库·postgresql·性能优化
翻斗包菜2 天前
PostgreSQL 日常维护完全指南:从基础操作到高级运维
运维·数据库·postgresql
刘晨鑫12 天前
PostgreSQL日常维护
数据库·postgresql
百结2142 天前
postgresql日常运用
数据库·postgresql·oracle
_下雨天.3 天前
PostgreSQL日常维护
数据库·postgresql