Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in HNSW Vector Search When Using ORDER BY with Non-Vector Fields in StarRocks #57653

Open
sharfy opened this issue Apr 4, 2025 · 0 comments
Labels
type/bug Something isn't working

Comments

@sharfy
Copy link

sharfy commented Apr 4, 2025

Steps to reproduce the behavior (Required)
Create the table
CREATE TABLE t_test_vector_table3 (
id BIGINT,
content_embedding ARRAY NOT NULL COMMENT "",
create_time DATETIME,
INDEX func_embedding1 (content_embedding) USING VECTOR (
"dim" = "5",
"index_type" = "hnsw",
"metric_type" = "l2_distance",
"efSearch" = "40",
"M" = "32",
"is_vector_normed" = "false"
)
)
PRIMARY KEY (id)
PROPERTIES (
"replication_num" = "1"
);
Insert sample data
INSERT INTO t_test_vector_table3 (id, content_embedding, create_time)
VALUES (1, [4, 5, 6, 7, 8], NOW());

INSERT INTO t_test_vector_table3 (id, content_embedding, create_time)
VALUES (2, [4, 5, 6, 7, 20], NOW());
Run the query
SELECT id, content_embedding, create_time
FROM t_test_vector_table3
ORDER BY create_time, approx_l2_distance([1, 1, 1, 1, 1], content_embedding)
LIMIT 1;
This query results in the following error:
Expected behavior (Required)
The query should return the nearest vector to [1, 1, 1, 1, 1] while also sorting by create_time.
No errors should occur when including create_time in the ORDER BY clause.
Real behavior (Required)
The query fails with the following error:
Internal error:[2024-12-07 16:17:34] /root/tenann/tenann/searcher/faiss_hnsw_ann_searcher.cc:304:
Error: Error in virtual void faiss::IndexHNSW::search(faiss::Index::idx_t, const float*,
faiss::Index::idx_t, float*, faiss::Index::idx_t*, const faiss::SearchParameters*) const at
/var/local/thirdparty/src/faiss-1.7.3/faiss/IndexHNSW.cpp:291: Error: 'k > 0' failed

StarRocks version (Required)

StarRocks 3.4

@sharfy sharfy added the type/bug Something isn't working label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant