Interface VectorStore
- All Superinterfaces:
Consumer<List<Document>>,DocumentWriter,VectorStoreRetriever
- 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 interfaceVectorStore.Builder<T extends VectorStore.Builder<T>>Builder interface for creating VectorStore instances. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidvoidAdds list ofDocuments to the vector store.default voidDeletes documents from the vector store using a string filter expression.voidDeletes documents from the vector store.voiddelete(Filter.Expression filterExpression) Deletes documents from the vector store based on filter criteria.default StringgetName()default <T> Optional<T> Returns the native client if available in this vector store implementation.Methods inherited from interface org.springframework.ai.document.DocumentWriter
writeMethods inherited from interface org.springframework.ai.vectorstore.VectorStoreRetriever
similaritySearch, similaritySearch
-
Method Details
-
getName
-
add
Adds list ofDocuments 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
-
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 Optionalinvalid input: '<'?> 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
-