pub struct Document {Show 14 fields
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>,
pub doc_type: DocumentType,
pub synonyms: Option<Vec<String>>,
pub route: Option<RouteDirective>,
pub priority: Option<u8>,
}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, DocumentType};
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()),
doc_type: DocumentType::KgEntry,
synonyms: None,
route: None,
priority: None,
};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
doc_type: DocumentTypeDocument classification derived from directives
synonyms: Option<Vec<String>>Synonyms extracted from directives (optional)
route: Option<RouteDirective>Optional route directive (provider/model)
priority: Option<u8>Optional priority directive (0-100)
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