问题
spring-ai在集成PGVector向量存储的时候会报错如下,那么就需要安装pgsql的vector扩展。
SQL [CREATE EXTENSION IF NOT EXISTS vector]; 错误: 无法打开扩展控制文件 "C:/Program Files/PostgreSQL/9.6/share/extension/vector.control": No such file or directory
根据pgvector的github的md文档显示只有Postgres13+的版本才能安装vector扩展。
vector 扩展安装
下载地址:
https://github.com/pgvector/pgvector/tags

1、下载后解压到任意目录
我这里解压后的根目录为 E:\Program Files\pgvector-0.7.4(编译时在命令行会使用cd进入到这个路径,进行编译安装)

2、在 Windows 上编译需要先下载 Visual Studio
下载地址:Visual Studio: 面向软件开发人员和 Teams 的 IDE 和代码编辑器

启动"VisualStudioSetup.exe"后,这里选择安装"使用C++的桌面开发"。

3、安装完成后,使用管理员模式打开cmd

依次执行以下命令便能够完成安装
bash
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
cd E:\Program Files\pgvector-0.7.4
set "PGROOT=C:\Program Files\PostgreSQL\16"
nmake /F Makefile.win
nmake /F Makefile.win install
执行效果如下:



4、最后在数据库连接工具中,选中具体的数据库实例,执行以下命令,就能扩展 vector 类型了
bash
CREATE EXTENSION vector;
