Class SimpleVectorStore
java.lang.Object
org.springframework.ai.vectorstore.SimpleVectorStore
- All Implemented Interfaces:
Consumer<List<Document>>
,DocumentWriter
,VectorStore
SimpleVectorStore is a simple implementation of the VectorStore interface.
It also provides methods to save the current state of the vectors to a file, and to
load vectors from a file.
For a deeper understanding of the mathematical concepts and computations involved in
calculating similarity scores among vectors, refer to this
[resource](https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_understanding_vectors).
- Author:
- Raphael Yu, Dingmeng Xue, Mark Pollack, Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds list ofDocument
s to the vector store.Deletes documents from the vector store.void
Deserialize the vector store content from a file in JSON format into memory.void
load
(org.springframework.core.io.Resource resource) Deserialize the vector store content from a resource in JSON format into memory.void
Serialize the vector store content into a file in JSON format.similaritySearch
(SearchRequest request) Retrieves documents by query embedding similarity and metadata filters to retrieve exactly the number of nearest-neighbor results that match the request criteria.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.vectorstore.VectorStore
accept, similaritySearch
-
Field Details
-
store
-
embeddingClient
-
-
Constructor Details
-
SimpleVectorStore
-
-
Method Details
-
add
Description copied from interface:VectorStore
Adds list ofDocument
s to the vector store.- Specified by:
add
in interfaceVectorStore
- Parameters:
documents
- the list of documents to store. Throws an exception if the underlying provider checks for duplicate IDs.
-
delete
Description copied from interface:VectorStore
Deletes documents from the vector store.- Specified by:
delete
in interfaceVectorStore
- Parameters:
idList
- list of document ids for which documents will be removed.- Returns:
-
similaritySearch
Description copied from interface:VectorStore
Retrieves documents by query embedding similarity and metadata filters to retrieve exactly the number of nearest-neighbor results that match the request criteria.- Specified by:
similaritySearch
in interfaceVectorStore
- Parameters:
request
- Search request for set search parameters, such as the query text, topK, similarity threshold and metadata filter expressions.- Returns:
- Returns documents th match the query request conditions.
-
save
Serialize the vector store content into a file in JSON format.- Parameters:
file
- the file to save the vector store content
-
load
Deserialize the vector store content from a file in JSON format into memory.- Parameters:
file
- the file to load the vector store content
-
load
public void load(org.springframework.core.io.Resource resource) Deserialize the vector store content from a resource in JSON format into memory.- Parameters:
resource
- the resource to load the vector store content
-