Skip to main content

search_endpoints

Function search_endpoints 

Source
pub fn search_endpoints(
    conn: &Connection,
    query_embedding: &[f32],
    limit: usize,
) -> Result<Vec<SearchResult>>
Expand description

k-nearest-neighbor search over semantic_endpoints (sqlite-vec’s documented MATCH ... AND k = ... query form). query_embedding must come from the same model as the vectors it’s compared against — see services::embedding_service. Bound as a raw little-endian f32 blob, the same wire format bin/populate_embeddings.rs writes (sqlite-vec accepts either that or a JSON array per-call, independent of how any given row was originally inserted, so this is a consistency choice, not a correctness requirement).

similarity is a simple 1 - distance transform of sqlite-vec’s L2 distance, not a true cosine-similarity computation; since embeddings are normalized (unit vectors), L2-distance ordering already matches cosine-similarity ordering, so result ranking is correct even though the displayed score is an approximation.