replace_chunks

Function replace_chunks 

Source
async fn replace_chunks(
    pool: &SqlitePool,
    document_id: &str,
    chunks: &[Chunk],
) -> Result<()>
Expand description

Atomically replaces all chunks (and their embeddings/FTS entries) for a document.

This function runs inside a single SQLite transaction to ensure consistency:

  1. Deletes old chunk_vectors rows for the document’s chunks.
  2. Deletes old embeddings metadata rows for the document’s chunks.
  3. Deletes old chunks_fts (FTS5) entries for the document.
  4. Deletes old chunks rows for the document.
  5. Inserts new chunks and their corresponding FTS entries.

§Arguments

  • pool — the database connection pool.
  • document_id — the UUID of the parent document.
  • chunks — the new set of chunks to insert.