pub struct SearchFilters { /* private fields */ }Expand description
Metadata narrowing applied to search hits after ranking.
Neither the vector index nor BM25 knows about languages or chunk kinds, so
narrowing happens here, against the chunk each hit resolves to. Because it
runs after ranking, the ranker has to be asked for more candidates than the
caller wants - see fetch_size.
use semtree_rag::SearchFilters;
let filters = SearchFilters::default()
.with_language_names(["rust"])?
.with_kind_names(["fn"])?
.with_path("src/");Implementations§
Source§impl SearchFilters
impl SearchFilters
Sourcepub fn with_languages(
self,
languages: impl IntoIterator<Item = Language>,
) -> Self
pub fn with_languages( self, languages: impl IntoIterator<Item = Language>, ) -> Self
Keep only chunks in these languages. Empty means “any”.
Sourcepub fn with_kinds(self, kinds: impl IntoIterator<Item = ChunkKind>) -> Self
pub fn with_kinds(self, kinds: impl IntoIterator<Item = ChunkKind>) -> Self
Keep only chunks of these kinds. Empty means “any”.
Sourcepub fn with_path(self, needle: impl Into<String>) -> Self
pub fn with_path(self, needle: impl Into<String>) -> Self
Keep only chunks whose path contains needle.
Sourcepub fn with_language_names<S: AsRef<str>>(
self,
names: impl IntoIterator<Item = S>,
) -> Result<Self, RagError>
pub fn with_language_names<S: AsRef<str>>( self, names: impl IntoIterator<Item = S>, ) -> Result<Self, RagError>
Like with_languages, from user-supplied names.
An unrecognized name is an error rather than a filter that matches
nothing, so a typo surfaces instead of looking like an empty index.
Sourcepub fn with_kind_names<S: AsRef<str>>(
self,
names: impl IntoIterator<Item = S>,
) -> Result<Self, RagError>
pub fn with_kind_names<S: AsRef<str>>( self, names: impl IntoIterator<Item = S>, ) -> Result<Self, RagError>
Like with_kinds, from user-supplied names.
Sourcepub fn fetch_size(&self, top_k: usize) -> usize
pub fn fetch_size(&self, top_k: usize) -> usize
How many candidates the ranker should return so that top_k survive the
filters. Unfiltered searches ask for exactly what they need.
Trait Implementations§
Source§impl Clone for SearchFilters
impl Clone for SearchFilters
Source§fn clone(&self) -> SearchFilters
fn clone(&self) -> SearchFilters
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SearchFilters
impl Debug for SearchFilters
Source§impl Default for SearchFilters
impl Default for SearchFilters
Source§fn default() -> SearchFilters
fn default() -> SearchFilters
Auto Trait Implementations§
impl Freeze for SearchFilters
impl RefUnwindSafe for SearchFilters
impl Send for SearchFilters
impl Sync for SearchFilters
impl Unpin for SearchFilters
impl UnsafeUnpin for SearchFilters
impl UnwindSafe for SearchFilters
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().