pub fn knn_search(
conn: &Connection,
embedding: &[f32],
namespace: &str,
k: usize,
) -> Result<Vec<(i64, f32)>, AppError>Expand description
Searches the entity_embeddings table for the k nearest neighbours
using pure-Rust cosine similarity.
v1.0.76: sqlite-vec was removed. The full table scan + in-process
cosine is O(N × D) per call. For namespaces with more than ~10k
entities, the operator should rely on FTS5 (hybrid-search) for
coarse filtering before reaching this function.
§Errors
AppError::Database— SQLite query failure.AppError::Embedding— invalid or mismatched embedding dimension.