Class RedisVectorStore

java.lang.Object
org.springframework.ai.vectorstore.RedisVectorStore
All Implemented Interfaces:
Consumer<List<Document>>, DocumentWriter, VectorStore, org.springframework.beans.factory.InitializingBean

public class RedisVectorStore extends Object implements VectorStore, org.springframework.beans.factory.InitializingBean
The RedisVectorStore is for managing and querying vector data in a Redis database. It offers functionalities like adding, deleting, and performing similarity searches on documents. The store utilizes RedisJSON and RedisSearch to handle JSON documents and to index and search vector data. It supports various vector algorithms (e.g., FLAT, HSNW) for efficient similarity searches. Additionally, it allows for custom metadata fields in the documents to be stored alongside the vector and content data. This class requires a RedisVectorStoreConfig configuration object for initialization, which includes settings like Redis URI, index name, field names, and vector algorithms. It also requires an EmbeddingClient to convert documents into embeddings before storing them.
Author:
Julien Ruaux, Christian Tzolov
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getJedis

      public redis.clients.jedis.JedisPooled getJedis()
    • add

      public void add(List<Document> documents)
      Description copied from interface: VectorStore
      Adds list of Documents to the vector store.
      Specified by:
      add in interface VectorStore
      Parameters:
      documents - the list of documents to store. Throws an exception if the underlying provider checks for duplicate IDs.
    • delete

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

      public List<Document> similaritySearch(SearchRequest request)
      Description copied from interface: VectorStore
      Retrieves documents by query embedding similarity and metadata filters to retrieve exactly the number of nearest-neighbor results that match the request criteria.
      Specified by:
      similaritySearch in interface VectorStore
      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.
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean