pub struct EnrichedRetriever { /* private fields */ }Expand description
Metadata-enhanced retrieval strategies
Implementations§
Source§impl EnrichedRetriever
impl EnrichedRetriever
Sourcepub fn with_config(config: EnrichedRetrievalConfig) -> Self
pub fn with_config(config: EnrichedRetrievalConfig) -> Self
Create with custom configuration
Sourcepub fn metadata_search(
&self,
query: &str,
graph: &KnowledgeGraph,
_analysis: &QueryAnalysis,
base_results: &[SearchResult],
) -> Result<Vec<SearchResult>>
pub fn metadata_search( &self, query: &str, graph: &KnowledgeGraph, _analysis: &QueryAnalysis, base_results: &[SearchResult], ) -> Result<Vec<SearchResult>>
Search chunks using enriched metadata
This method boosts chunks that match:
- Query keywords present in chunk keywords (TF-IDF extracted)
- Chapter/Section mentioned in query
- Summary content relevant to query
Sourcepub fn filter_by_structure(
&self,
query: &str,
results: Vec<SearchResult>,
graph: &KnowledgeGraph,
) -> Result<Vec<SearchResult>>
pub fn filter_by_structure( &self, query: &str, results: Vec<SearchResult>, graph: &KnowledgeGraph, ) -> Result<Vec<SearchResult>>
Filter chunks by chapter or section
Example: “What does Socrates say in Chapter 1?” -> filter to Chapter 1 chunks
Sourcepub fn boost_with_metadata(
&self,
results: Vec<SearchResult>,
query: &str,
graph: &KnowledgeGraph,
) -> Result<Vec<SearchResult>>
pub fn boost_with_metadata( &self, results: Vec<SearchResult>, query: &str, graph: &KnowledgeGraph, ) -> Result<Vec<SearchResult>>
Boost results based on enriched metadata
Sourcepub fn get_chapter_chunks<'a>(
&self,
chapter_name: &str,
graph: &'a KnowledgeGraph,
) -> Vec<&'a TextChunk>
pub fn get_chapter_chunks<'a>( &self, chapter_name: &str, graph: &'a KnowledgeGraph, ) -> Vec<&'a TextChunk>
Get chunks from a specific chapter
Sourcepub fn get_section_chunks<'a>(
&self,
section_name: &str,
graph: &'a KnowledgeGraph,
) -> Vec<&'a TextChunk>
pub fn get_section_chunks<'a>( &self, section_name: &str, graph: &'a KnowledgeGraph, ) -> Vec<&'a TextChunk>
Get chunks from a specific section
Sourcepub fn search_by_keywords(
&self,
keywords: &[String],
graph: &KnowledgeGraph,
top_k: usize,
) -> Vec<SearchResult>
pub fn search_by_keywords( &self, keywords: &[String], graph: &KnowledgeGraph, top_k: usize, ) -> Vec<SearchResult>
Search by keywords extracted from chunks
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnrichedRetriever
impl RefUnwindSafe for EnrichedRetriever
impl Send for EnrichedRetriever
impl Sync for EnrichedRetriever
impl Unpin for EnrichedRetriever
impl UnsafeUnpin for EnrichedRetriever
impl UnwindSafe for EnrichedRetriever
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
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>
Converts
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>
Converts
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