pub struct Document {
pub doc_id: Option<DocumentId>,
pub content: String,
pub metadata: Value,
pub score: Option<f32>,
}Expand description
One retrieved document with optional similarity score.
Fields§
§doc_id: Option<DocumentId>Backend-assigned stable id, when the originating
VectorStore mints one. Pass back to
VectorStore::update / VectorStore::delete to mutate
or remove this document. None for embedded usages where
stable identity isn’t tracked.
content: StringBody text. Implementations may store any UTF-8 payload.
metadata: ValueFree-form metadata — stored alongside the document for filtering / display. Use a JSON object by convention.
score: Option<f32>Similarity score from the retriever, if available. Higher = better match. Comparable only within a single query’s result set.
Implementations§
Source§impl Document
impl Document
Sourcepub fn new(content: impl Into<String>) -> Self
pub fn new(content: impl Into<String>) -> Self
Convenience: build a document with empty metadata and no score.
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Builder-style metadata setter.
Sourcepub fn with_doc_id(self, id: impl Into<DocumentId>) -> Self
pub fn with_doc_id(self, id: impl Into<DocumentId>) -> Self
Builder-style doc_id setter — backends use this when surfacing previously-indexed documents so callers can mutate or delete via the same id.