Interface VectorStore
- All Superinterfaces:
Consumer<List<Document>>
,DocumentWriter
- All Known Implementing Classes:
AbstractObservationVectorStore
,AzureVectorStore
,CassandraVectorStore
,ChromaVectorStore
,CoherenceVectorStore
,CosmosDBVectorStore
,CouchbaseSearchVectorStore
,ElasticsearchVectorStore
,GemFireVectorStore
,HanaCloudVectorStore
,MariaDBVectorStore
,MilvusVectorStore
,MongoDBAtlasVectorStore
,Neo4jVectorStore
,OpenSearchVectorStore
,OracleVectorStore
,PgVectorStore
,PineconeVectorStore
,QdrantVectorStore
,RedisVectorStore
,SimpleVectorStore
,TypesenseVectorStore
,WeaviateVectorStore
The
VectorStore
interface defines the operations for managing and querying
documents in a vector database. It extends DocumentWriter
to support document
writing operations. Vector databases are specialized for AI applications, performing
similarity searches based on vector representations of data rather than exact matches.
This interface allows for adding, deleting, and searching documents based on their
similarity to a given query.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
VectorStore.Builder<T extends VectorStore.Builder<T>>
Builder interface for creating VectorStore instances. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
void
Adds list ofDocument
s to the vector store.default void
Deletes documents from the vector store using a string filter expression.void
Deletes documents from the vector store.void
delete
(Filter.Expression filterExpression) Deletes documents from the vector store based on filter criteria.default String
getName()
default <T> Optional<T>
Returns the native client if available in this vector store implementation.similaritySearch
(String query) Retrieves documents by query embedding similarity using the defaultSearchRequest
's' search criteria.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 interface org.springframework.ai.document.DocumentWriter
write
-
Method Details
-
getName
-
add
Adds list ofDocument
s to the vector store.- Parameters:
documents
- the list of documents to store. Throws an exception if the underlying provider checks for duplicate IDs.
-
accept
-
delete
Deletes documents from the vector store.- Parameters:
idList
- list of document ids for which documents will be removed.
-
delete
Deletes documents from the vector store based on filter criteria.- Parameters:
filterExpression
- Filter expression to identify documents to delete- Throws:
IllegalStateException
- if the underlying delete causes an exception
-
delete
Deletes documents from the vector store using a string filter expression. Converts the string filter to an Expression object and delegates todelete(Filter.Expression)
.- Parameters:
filterExpression
- String representation of the filter criteria- Throws:
IllegalArgumentException
- if the filter expression is nullIllegalStateException
- if the underlying delete causes an exception
-
similaritySearch
Retrieves documents by query embedding similarity and metadata filters to retrieve exactly the number of nearest-neighbor results that match the request criteria.- 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.
-
similaritySearch
Retrieves documents by query embedding similarity using the defaultSearchRequest
's' search criteria.- Parameters:
query
- Text to use for embedding similarity comparison.- Returns:
- Returns a list of documents that have embeddings similar to the query text embedding.
-
getNativeClient
Returns the native client if available in this vector store implementation. Note on usage: 1. Returns empty Optional when no native client is available 2. Due to Java type erasure, runtime type checking is not possible Example usage: When working with implementation with known native client: Optionalclient = vectorStore.getNativeClient(); Note: Using Optional<?> will return the native client if one exists, rather than an empty Optional. For type safety, prefer using the specific client type. - Type Parameters:
T
- The type of the native client- Returns:
- Optional containing native client if available, empty Optional otherwise
-