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', '人工智能和机器学习');"
相关推荐
星星也在雾里5 小时前
PgBouncer 解决 PostgreSQL 连接数超限 + 可视化监控
数据库·postgresql
zhojiew10 小时前
在本地PostgreSQL使用pgvector构建生成式 AI 应用的实践
数据库·人工智能·postgresql
snowfoootball12 小时前
解决低版本navicat连接PostgreSQl的不兼容报错问题
数据库·postgresql
csdn小瓯14 小时前
PostgreSQL迁移实战:从SQLite到生产级数据库的平滑演进
数据库·postgresql·sqlite
IvorySQL18 小时前
用生成列提升 JSONB 查询效率:PostgreSQL 三种索引方案实测对比
数据库·postgresql
丷丩19 小时前
Postgresql基础实践教程
数据库·postgresql
IvorySQL19 小时前
IvorySQL & PostgreSQL 国内镜像服务上线——更快拉取,更稳体验
数据库·postgresql
l1t19 小时前
DeepSeek总结的PostgreSQL 在 AI 基础设施中日益增长的作用
人工智能·postgresql
Languorous.2 天前
Linux 登录用户、主机名、提示符详解(新手不迷路)
linux·数据库·postgresql
张~颜2 天前
PostgreSQL复制槽
数据库·postgresql