pub fn topk(
embeddings: &FlatEmbeddings,
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.
The FlatEmbeddings data is shared via Arc::clone (a refcount bump, zero
bytes copied) when building the cached HNSW index.