-
docker pull ankane/pgvector
-
docker run --name mypgvector -e POSTGRES_PASSWORD=654321 -p 5433:5432 -d ankane/pgvector
-
Use DBeaver to connect pgvector, host:localhost, port:5433, username:postgres, password:654321
-
Run SQL:
CREATE EXTENSION vector;
CREATE TABLE test1 (id bigserial PRIMARY KEY, name VARCHAR(100), embedding vector(3));
INSERT INTO test1 (name,embedding) VALUES ('a','[1,2,3]'), ('b','[4,5,6]'), ('c','[7,8,9]');
SELECT * FROM test1 ORDER BY embedding <-> '[3,4,5]';