pub struct MultiVectorRetriever<S: VectorStore> { /* private fields */ }Expand description
A retriever that maps multiple child vectors back to parent documents.
Each parent document can have multiple sub-documents (e.g., summaries, smaller chunks) stored in the vector store. Retrieval finds relevant sub-documents, then returns the original parent documents.
Implementations§
Source§impl<S: VectorStore + 'static> MultiVectorRetriever<S>
impl<S: VectorStore + 'static> MultiVectorRetriever<S>
Sourcepub fn new(
vectorstore: Arc<S>,
embeddings: Arc<dyn Embeddings>,
k: usize,
) -> Self
pub fn new( vectorstore: Arc<S>, embeddings: Arc<dyn Embeddings>, k: usize, ) -> Self
Create a new MultiVectorRetriever.
vectorstore: the vector store to search for child documents.embeddings: the embeddings provider for embedding child documents.k: the number of child documents to retrieve for parent lookup.
Sourcepub fn with_id_key(self, key: impl Into<String>) -> Self
pub fn with_id_key(self, key: impl Into<String>) -> Self
Set a custom metadata key linking child documents to their parent ID.
Defaults to "parent_id".
Sourcepub async fn add_documents(
&self,
parent_docs: Vec<Document>,
child_docs: Vec<Document>,
) -> Result<(), SynapticError>
pub async fn add_documents( &self, parent_docs: Vec<Document>, child_docs: Vec<Document>, ) -> Result<(), SynapticError>
Add parent documents and their associated child documents.
Parents are stored in the internal docstore. Children are embedded and
added to the vector store. Each child document must have the id_key
metadata field set to the parent document’s ID.
Trait Implementations§
Source§impl<S: VectorStore + 'static> Retriever for MultiVectorRetriever<S>
impl<S: VectorStore + 'static> Retriever for MultiVectorRetriever<S>
Auto Trait Implementations§
impl<S> Freeze for MultiVectorRetriever<S>
impl<S> !RefUnwindSafe for MultiVectorRetriever<S>
impl<S> Send for MultiVectorRetriever<S>
impl<S> Sync for MultiVectorRetriever<S>
impl<S> Unpin for MultiVectorRetriever<S>
impl<S> UnsafeUnpin for MultiVectorRetriever<S>
impl<S> !UnwindSafe for MultiVectorRetriever<S>
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