Interface VectorStore

All Superinterfaces:
Consumer<List<Document>>, DocumentWriter
All Known Implementing Classes:
AzureVectorStore, ChromaVectorStore, MilvusVectorStore, Neo4jVectorStore, PgVectorStore, PineconeVectorStore, QdrantVectorStore, RedisVectorStore, SimpleVectorStore, WeaviateVectorStore

public interface VectorStore extends DocumentWriter
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

    • 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

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

      List<Document> 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.
      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

      default List<Document> similaritySearch(String query)
      Retrieves documents by query embedding similarity using the default SearchRequest'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.