Skip to main content

flatten_embedded

Function flatten_embedded 

Source
pub fn flatten_embedded<Doc: Serialize, R>(
    documents: Vec<(Doc, Vec<Embedding>)>,
    f: impl FnMut(&Value, Embedding) -> Result<R, VectorStoreError>,
) -> Result<Vec<R>, VectorStoreError>
Expand description

Serializes each document to JSON once, then applies f to every (document, embedding) pair, flattening the results into a single vector.

This is the shared shape of most InsertDocuments implementations: build one backend record per embedding, carrying the owning document’s serialized form.