Class SimpleVectorStore
java.lang.Object
org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
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, Sebastien Deleuze, Ilayaperumal Gopinathan, Thomas Vitale, Jemin Huh
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static final class
Nested classes/interfaces inherited from interface org.springframework.ai.vectorstore.VectorStore
VectorStore.Builder<T extends VectorStore.Builder<T>>
-
Field Summary
FieldsFields inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
batchingStrategy, embeddingModel
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionbuilder
(EmbeddingModel embeddingModel) Creates an instance of SimpleVectorStore builder.createObservationContextBuilder
(String operationName) Create a newVectorStoreObservationContext.Builder
instance.void
Perform the actual add operation.void
Perform the actual delete operation.doSimilaritySearch
(SearchRequest request) Perform the actual similarity search operation.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.Methods inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
add, delete, delete, doDelete, similaritySearch
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.document.DocumentWriter
write
Methods inherited from interface org.springframework.ai.vectorstore.VectorStore
accept, delete, getName, getNativeClient, similaritySearch
-
Field Details
-
store
-
-
Constructor Details
-
SimpleVectorStore
-
-
Method Details
-
builder
Creates an instance of SimpleVectorStore builder.- Returns:
- the SimpleVectorStore builder.
-
doAdd
Description copied from class:AbstractObservationVectorStore
Perform the actual add operation.- Specified by:
doAdd
in classAbstractObservationVectorStore
- Parameters:
documents
- the documents to add
-
doDelete
Description copied from class:AbstractObservationVectorStore
Perform the actual delete operation.- Specified by:
doDelete
in classAbstractObservationVectorStore
- Parameters:
idList
- the list of document IDs to delete
-
doSimilaritySearch
Description copied from class:AbstractObservationVectorStore
Perform the actual similarity search operation.- Specified by:
doSimilaritySearch
in classAbstractObservationVectorStore
- Parameters:
request
- the search request- Returns:
- the list of documents that 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
-
createObservationContextBuilder
Description copied from class:AbstractObservationVectorStore
Create a newVectorStoreObservationContext.Builder
instance.- Specified by:
createObservationContextBuilder
in classAbstractObservationVectorStore
- Parameters:
operationName
- the operation name- Returns:
- the observation context builder
-