Class VectorStoreDocumentRetriever
java.lang.Object
org.springframework.ai.rag.retrieval.search.VectorStoreDocumentRetriever
- All Implemented Interfaces:
Function<Query,,List<org.springframework.ai.document.Document>> DocumentRetriever
Retrieves documents from a vector store that are semantically similar to the input
query. It supports filtering based on metadata, similarity threshold, and top-k
results.
Example usage:
VectorStoreDocumentRetriever retriever = VectorStoreDocumentRetriever.builder()
.vectorStore(vectorStore)
.similarityThreshold(0.73)
.topK(5)
.filterExpression(filterExpression)
.build();
List<Document> documents = retriever.retrieve(new Query("example query"));
The FILTER_EXPRESSION context key can be used to provide a filter expression
for a specific query. This key accepts either a string representation of a filter
expression or a Filter.Expression object directly.
- Since:
- 1.0.0
- Author:
- Thomas Vitale
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVectorStoreDocumentRetriever(org.springframework.ai.vectorstore.VectorStore vectorStore, Double similarityThreshold, Integer topK, Supplier<org.springframework.ai.vectorstore.filter.Filter.Expression> filterExpression) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.rag.retrieval.search.DocumentRetriever
apply
-
Field Details
-
FILTER_EXPRESSION
- See Also:
-
-
Constructor Details
-
VectorStoreDocumentRetriever
-
-
Method Details
-
retrieve
Description copied from interface:DocumentRetrieverRetrieves relevant documents from an underlying data source based on the given query.- Specified by:
retrievein interfaceDocumentRetriever- Parameters:
query- The query to use for retrieving documents- Returns:
- The list of relevant documents
-
builder
-