Files
postgres-ts-vectors/tests/test-3-vector.sql
Maxime Killinger f7b98d2c02 feat: Add comprehensive test suite and cleanup step
- Split validation into 4 granular CI steps (Config, Timescale, Vector, Hybrid)
- Added cleanup step for Docker images in CI
- Created SQL test scripts in tests/ for robustness
2025-12-19 13:59:55 +01:00

28 lines
644 B
SQL

-- Test 3: VectorChord / pgvector
\set ON_ERROR_STOP on
DROP TABLE IF EXISTS items;
CREATE TABLE items (
id bigserial PRIMARY KEY,
embedding vector(3)
);
INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]'), ('[1.1, 2.1, 3.1]');
-- Create VectorChord Index
CREATE INDEX ON items USING vchordrq (embedding vector_l2_ops);
-- Search
DO $$
DECLARE
closest_id int;
BEGIN
SELECT id INTO closest_id FROM items ORDER BY embedding <-> '[1,2,3]' LIMIT 1;
IF closest_id != 1 THEN
RAISE EXCEPTION 'Vector search failed. Expected ID 1, got %', closest_id;
END IF;
RAISE NOTICE 'Vector Check: OK';
END
$$;