Skip to content

Retrieving Data

When a query meets all your and the retrievers requirements (i.e. extra generated context, embeddings), documents can then be retrieved by a retriever.

A retriever implements the Retrieve<S> trait.

The Retrieve<S> trait

The Retrieve<S> trait is defined as follows:

pub trait Retrieve<S: SearchStrategy>: Send + Sync {
async fn retrieve(
&self,
search_strategy: &S,
query: Query<states::Pending>,
) -> Result<Query<states::Retrieved>>;
}

The retriever retrieves documents for the given SearchStrategy. Retrieved documents are then added to the query with query.retrieved_documents(documents). Any additional configuration is set on the SearchStrategy. The trait is also implemented for closures, enabling full customization where needed.

Built in retrievers

NameDescriptionFeature Flag
QdrantImplements both Retrieve<SimilaritySingleEmbedding> and Retrieve<HybridSearch>.qdrant
LanceDBImplements Retrieve<SimilaritySingleEmbedding>.lancedb