Skip to content

fix(ruvector-router-core): rebuild HNSW index from storage on open + fix result heap orientation#460

Open
CoolDude1969 wants to merge 1 commit into
ruvnet:mainfrom
CoolDude1969:fix/hnsw-index-rebuild-and-heap-orientation
Open

fix(ruvector-router-core): rebuild HNSW index from storage on open + fix result heap orientation#460
CoolDude1969 wants to merge 1 commit into
ruvnet:mainfrom
CoolDude1969:fix/hnsw-index-rebuild-and-heap-orientation

Conversation

@CoolDude1969
Copy link
Copy Markdown

Problem

Two bugs causing search() to always return 0 results after restart:

  1. VectorDB::new() never rebuilt the index from storage — a fresh empty
    HnswIndex was created every time, so all persisted vectors were
    invisible to search. Closes ruvector-router-core HNSW: search returns 0 results from inserted vectors at scale (recall@1 << 1.0) #430.

  2. search_knn_internal used a min-heap for result — it must be a
    max-heap so peek() returns the furthest candidate for correct pruning.
    With a min-heap, valid candidates were silently discarded at scale.

Changes

  • vector_db.rs: rebuild index from storage in VectorDB::new() using
    get_all_ids() + insert_batch(); fix total_vectors stat initial value
  • index.rs: change result heap to BinaryHeap<Reverse> (max-heap);
    fix termination and replacement conditions
  • index.rs: remove ef_construction.min(m*2) beam clamp in insert()

Before / After

Before: ruvector search ... → Found 0 results
After: 1. 1 (score: 0.0000)
2. 2 (score: 0.0061)

…NSW result heap

  - VectorDB::new() now loads all persisted vectors into the HNSW index
    on startup, fixing search() always returning 0 results after restart
    (closes ruvnet#430)

  - Fix result heap in search_knn_internal: was min-heap, must be max-heap
    so peek() returns the furthest result for correct pruning at scale

  - Remove ef_construction.min(m*2) beam clamp in insert() so the full
    candidate pool is used during graph construction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ruvector-router-core HNSW: search returns 0 results from inserted vectors at scale (recall@1 << 1.0)

1 participant