pub fn topk(
embeddings: &Arc<[Vec<f32>]>,
query: &[f32],
top_k: usize,
) -> Vec<(usize, f32)>Expand description
Returns the top-k (index, similarity) pairs for query over embeddings,
sorted by descending similarity.
Small corpora use exact brute force. Large corpora build (once) and reuse a cached HNSW index. Falls back to brute force on lock failure.
embeddings is taken as Arc<[Vec<f32>]> (the same allocation the caller
already holds for per-query scoring) so building the cached HNSW index is an
Arc::clone — a refcount bump, not a second full-precision corpus copy.