pub struct DocumentChunk {
pub id: String,
pub content: String,
pub metadata: HashMap<String, String>,
pub embedding: Vec<f32>,
pub document_id: String,
pub position: usize,
pub length: usize,
}Expand description
Document chunk for processing
Fields§
§id: StringUnique chunk ID
content: StringChunk content
metadata: HashMap<String, String>Chunk metadata
embedding: Vec<f32>Embedding vector
document_id: StringSource document ID
position: usizeChunk position in document
length: usizeChunk length
Implementations§
Source§impl DocumentChunk
impl DocumentChunk
Sourcepub fn new(
id: String,
content: String,
metadata: HashMap<String, String>,
embedding: Vec<f32>,
document_id: String,
position: usize,
length: usize,
) -> Self
pub fn new( id: String, content: String, metadata: HashMap<String, String>, embedding: Vec<f32>, document_id: String, position: usize, length: usize, ) -> Self
Create a new document chunk
Sourcepub fn get_metadata(&self, key: &str) -> Option<&String>
pub fn get_metadata(&self, key: &str) -> Option<&String>
Get metadata value
Sourcepub fn set_metadata(&mut self, key: String, value: String)
pub fn set_metadata(&mut self, key: String, value: String)
Set metadata value
Sourcepub fn similarity(&self, other: &DocumentChunk) -> f32
pub fn similarity(&self, other: &DocumentChunk) -> f32
Calculate similarity with another chunk
Trait Implementations§
Source§impl Clone for DocumentChunk
impl Clone for DocumentChunk
Source§fn clone(&self) -> DocumentChunk
fn clone(&self) -> DocumentChunk
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DocumentChunk
impl Debug for DocumentChunk
Source§impl<'de> Deserialize<'de> for DocumentChunk
impl<'de> Deserialize<'de> for DocumentChunk
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 DocumentChunk
impl RefUnwindSafe for DocumentChunk
impl Send for DocumentChunk
impl Sync for DocumentChunk
impl Unpin for DocumentChunk
impl UnwindSafe for DocumentChunk
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