pub struct Filter {
pub session_id: Option<String>,
pub terms: Vec<FilterTerm>,
}Expand description
Pre-scoring filter applied by crate::Mnemo::recall (Phase 12.6).
session_id restricts candidates to a single session (when the
memory’s session_id is set). The terms are AND-ed metadata
conditions evaluated against each candidate’s metadata map; see
FilterTerm for the shapes.
When an ANN index is present, the filter is applied after the ANN
shortlist step, so a selective filter can starve the result below
top_k. Recall handles that automatically via the Phase 12.1
short-results-on-indexed-path fix (widen 2×, then exact scan).
Fields§
§session_id: Option<String>Only candidates whose Memory.session_id equals this value.
Candidates without a session_id are excluded when this is set.
terms: Vec<FilterTerm>AND-ed metadata conditions. Empty → no metadata constraints.
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn new_session(session: impl Into<String>) -> Self
pub fn new_session(session: impl Into<String>) -> Self
Builder helper: a filter that keeps only memories in session.
Sourcepub fn with_session(self, session: impl Into<String>) -> Self
pub fn with_session(self, session: impl Into<String>) -> Self
Restrict to one session_id (builder form).
Sourcepub fn metadata_exists(self, key: impl Into<String>) -> Self
pub fn metadata_exists(self, key: impl Into<String>) -> Self
Require metadata[key] to exist (any value).
Sourcepub fn metadata_eq(self, key: impl Into<String>, value: Value) -> Self
pub fn metadata_eq(self, key: impl Into<String>, value: Value) -> Self
Require metadata[key] to equal value.
Sourcepub fn metadata_in(self, key: impl Into<String>, values: Vec<Value>) -> Self
pub fn metadata_in(self, key: impl Into<String>, values: Vec<Value>) -> Self
Require metadata[key] to be one of values.
Sourcepub fn metadata_range(
self,
key: impl Into<String>,
min: Option<f64>,
max: Option<f64>,
) -> Self
pub fn metadata_range( self, key: impl Into<String>, min: Option<f64>, max: Option<f64>, ) -> Self
Require metadata[key] to be a number in [min, max].