pgvector.git / summary / log / commit / refs

commit    b0665dca96f0a186d438adbd1c35945d71da5490
Author:   Andrew Kane <andrew@ankane.org>
Date:     Tue Nov 03 11:12:45 2026 +0000

    Added test for sparsevec query with max non-zero elements [skip ci]


test/expected/hnsw_sparsevec.out | 11 +++++++++++ test/sql/hnsw_sparsevec.sql | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/test/expected/hnsw_sparsevec.out b/test/expected/hnsw_sparsevec.out index 2a6fe7c9..7d4e5b9b 100644 --- a/test/expected/hnsw_sparsevec.out +++ b/test/expected/hnsw_sparsevec.out @@ -110,3 +110,14 @@ CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops); INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1001])::vector::sparsevec); ERROR: sparsevec cannot have more than 1000 non-zero elements for hnsw index DROP TABLE t; +CREATE TABLE t (val sparsevec(16000)); +CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops); +INSERT INTO t (val) VALUES ('{}/16000'), ('{1:1}/16000'); +SELECT * FROM t ORDER BY val <-> array_fill(1, ARRAY[16000])::vector::sparsevec; + val +------------- + {1:1}/16000 + {}/16000 +(2 rows) + +DROP TABLE t; diff --git a/test/sql/hnsw_sparsevec.sql b/test/sql/hnsw_sparsevec.sql index 4ec07025..f083d372 100644 --- a/test/sql/hnsw_sparsevec.sql +++ b/test/sql/hnsw_sparsevec.sql @@ -66,3 +66,9 @@ TRUNCATE t; CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops); INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1001])::vector::sparsevec); DROP TABLE t; + +CREATE TABLE t (val sparsevec(16000)); +CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops); +INSERT INTO t (val) VALUES ('{}/16000'), ('{1:1}/16000'); +SELECT * FROM t ORDER BY val <-> array_fill(1, ARRAY[16000])::vector::sparsevec; +DROP TABLE t; [parent: 5e62a12786ff]