Document

Struct Document 

Source
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 path
  • title - Document title (used for display and basic search)
  • body - Full text content
  • description - Optional short description (extracted or provided)
  • summarization - Optional AI-generated summary
  • stub - Optional brief excerpt
  • tags - Optional categorization tags (often from knowledge graph)
  • rank - Optional relevance score from search results
  • source_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: String

Unique identifier for the document

§url: String

URL to the document

§title: String

Title of the document

§body: String

The 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: Option<Vec<String>>

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

Source

pub fn with_source_haystack(self, haystack_location: String) -> Self

Set the source haystack for this document

Source

pub fn get_source_haystack(&self) -> Option<&String>

Get the source haystack location

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Document

Source§

fn default() -> Document

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Document

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Document

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,