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

public interface VectorStore extends DocumentWriter, VectorStoreRetriever
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.
  • Method Details

    • getName

      default String getName()
    • add

      void add(List<Document> documents)
      Adds list of Documents to the vector store.
      Parameters:
      documents - the list of documents to store. Throws an exception if the underlying provider checks for duplicate IDs.
    • accept

      default void accept(List<Document> documents)
      Specified by:
      accept in interface Consumer<List<Document>>
    • delete

      void delete(List<String> idList)
      Deletes documents from the vector store.
      Parameters:
      idList - list of document ids for which documents will be removed.
    • delete

      void delete(Filter.Expression filterExpression)
      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

      default void delete(String filterExpression)
      Deletes documents from the vector store using a string filter expression. Converts the string filter to an Expression object and delegates to delete(Filter.Expression).
      Parameters:
      filterExpression - String representation of the filter criteria
      Throws:
      IllegalArgumentException - if the filter expression is null
      IllegalStateException - if the underlying delete causes an exception
    • getNativeClient

      default <T> Optional<T> 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: Optional client = 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