pub struct RecallItem {
pub memory_id: i64,
pub name: String,
pub namespace: String,
pub memory_type: String,
pub description: String,
pub snippet: String,
pub distance: f32,
pub score: f32,
pub source: String,
pub graph_depth: Option<u32>,
}Expand description
Individual item returned by the recall query.
The memory_type field is serialised as "type" in JSON to maintain
compatibility with external clients — the Rust name uses memory_type
to avoid conflict with the reserved keyword.
§Examples
use sqlite_graphrag::output::RecallItem;
let item = RecallItem {
memory_id: 7,
name: "nota-rust".into(),
namespace: "global".into(),
memory_type: "user".into(),
description: "aprendizado de Rust".into(),
snippet: "ownership e borrowing".into(),
distance: 0.12,
score: 0.88,
source: "direct".into(),
graph_depth: None,
};
let json = serde_json::to_string(&item).unwrap();
// Rust field `memory_type` appears as `"type"` in JSON.
assert!(json.contains("\"type\":\"user\""));
assert!(!json.contains("memory_type"));
assert!(json.contains("\"distance\":0.12"));Fields§
§memory_id: i64§name: String§namespace: String§memory_type: String§description: String§snippet: String§distance: f32§score: f32Cosine similarity in [0.0, 1.0] derived as 1.0 - distance and clamped
to that interval. Always populated to satisfy the documented contract
(M-A5 in v1.0.40); higher means more similar. For graph hits the value
reflects the hop-derived distance proxy and should be interpreted
alongside graph_depth rather than as a true cosine score.
source: String§graph_depth: Option<u32>Number of graph hops between this match and the seed memories.
Set to None for direct vector matches (where distance is meaningful)
and to Some(N) for traversal results, with N=0 when the depth could
not be tracked precisely. Added in v1.0.23 to disambiguate graph results
from the distance: 0.0 placeholder previously used for graph entries.
Field is omitted from JSON output when None.
Implementations§
Source§impl RecallItem
impl RecallItem
Sourcepub fn score_from_distance(distance: f32) -> f32
pub fn score_from_distance(distance: f32) -> f32
Computes the similarity score from a vector distance, clamped to
[0.0, 1.0]. Cosine distance returned by sqlite-vec lives in [0, 2]
in theory but the embedder produces unit-norm vectors so the practical
range is [0, 1]. Centralized so every constructor keeps the contract.
Trait Implementations§
Source§impl Clone for RecallItem
impl Clone for RecallItem
Source§fn clone(&self) -> RecallItem
fn clone(&self) -> RecallItem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RecallItem
impl RefUnwindSafe for RecallItem
impl Send for RecallItem
impl Sync for RecallItem
impl Unpin for RecallItem
impl UnsafeUnpin for RecallItem
impl UnwindSafe for RecallItem
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more