Skip to main content

upsert_embedding

Function upsert_embedding 

Source
pub async fn upsert_embedding(
    conn: &Connection,
    source_type: &str,
    source_path: &str,
    source_id: Option<i64>,
    model: &str,
    last_commit: Option<&str>,
    staleness: f32,
    chunk_text: &str,
    embedding_bytes: &[u8],
    vec_conn: Option<&VecConnection>,
) -> Result<(), Error>
Expand description

Insert or replace one embedding row.

Uses INSERT OR REPLACE keyed on the UNIQUE constraint (source_type, source_path, source_id) so re-indexing a symbol replaces the old vector in a single statement — no SELECT-then-DELETE round-trip.

The corresponding row in vec_embeddings is also updated when a VecConnection is provided (best-effort; errors are silently ignored).