pub struct Document {
pub id: String,
pub url: String,
pub title: String,
pub body: String,
pub description: Option<String>,
pub summarization: Option<String>,
pub stub: Option<String>,
pub tags: Option<Vec<String>>,
pub rank: Option<u64>,
pub source_haystack: Option<String>,
}Expand description
The central document type representing indexed and searchable content.
Documents are the primary unit of content in Terraphim. They can come from various sources (local files, web pages, API responses) and are indexed for semantic search using knowledge graphs.
§Fields
id- Unique identifier (typically a UUID or URL-based ID)url- Source URL or file pathtitle- Document title (used for display and basic search)body- Full text contentdescription- Optional short description (extracted or provided)summarization- Optional AI-generated summarystub- Optional brief excerpttags- Optional categorization tags (often from knowledge graph)rank- Optional relevance score from search resultssource_haystack- Optional identifier of the data source that provided this document
§Examples
use terraphim_types::Document;
let doc = Document {
id: "rust-book-ch1".to_string(),
url: "https://doc.rust-lang.org/book/ch01-00-getting-started.html".to_string(),
title: "Getting Started".to_string(),
body: "Let's start your Rust journey...".to_string(),
description: Some("Introduction to Rust programming".to_string()),
summarization: None,
stub: None,
tags: Some(vec!["rust".to_string(), "tutorial".to_string()]),
rank: Some(95),
source_haystack: Some("rust-docs".to_string()),
};Fields§
§id: StringUnique identifier for the document
url: StringURL to the document
title: StringTitle of the document
body: StringThe document body
description: Option<String>A short description of the document (extracted from content)
summarization: Option<String>AI-generated summarization of the document content
stub: Option<String>A short excerpt of the document
Tags for the document
rank: Option<u64>Rank of the document in the search results
source_haystack: Option<String>Source haystack location that this document came from
Implementations§
Source§impl Document
impl Document
Sourcepub fn with_source_haystack(self, haystack_location: String) -> Self
pub fn with_source_haystack(self, haystack_location: String) -> Self
Set the source haystack for this document
Sourcepub fn get_source_haystack(&self) -> Option<&String>
pub fn get_source_haystack(&self) -> Option<&String>
Get the source haystack location
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more