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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final recordstatic final classConfiguration for the Redis vector store. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRedisVectorStore(RedisVectorStore.RedisVectorStoreConfig config, EmbeddingClient embeddingClient) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds list ofDocuments to the vector store.voidDeletes documents from the vector store.redis.clients.jedis.JedisPooledgetJedis()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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.vectorstore.VectorStore
accept, similaritySearch
-
Field Details
-
DEFAULT_URI
- See Also:
-
DEFAULT_INDEX_NAME
- See Also:
-
DEFAULT_CONTENT_FIELD_NAME
- See Also:
-
DEFAULT_EMBEDDING_FIELD_NAME
- See Also:
-
DEFAULT_PREFIX
- See Also:
-
DEFAULT_VECTOR_ALGORITHM
-
DISTANCE_FIELD_NAME
- See Also:
-
-
Constructor Details
-
RedisVectorStore
public RedisVectorStore(RedisVectorStore.RedisVectorStoreConfig config, EmbeddingClient embeddingClient)
-
-
Method Details
-
getJedis
public redis.clients.jedis.JedisPooled getJedis() -
add
Description copied from interface:VectorStoreAdds list ofDocuments to the vector store.- Specified by:
addin interfaceVectorStore- Parameters:
documents- the list of documents to store. Throws an exception if the underlying provider checks for duplicate IDs.
-
delete
Description copied from interface:VectorStoreDeletes documents from the vector store.- Specified by:
deletein interfaceVectorStore- Parameters:
idList- list of document ids for which documents will be removed.- Returns:
-
similaritySearch
Description copied from interface:VectorStoreRetrieves documents by query embedding similarity and metadata filters to retrieve exactly the number of nearest-neighbor results that match the request criteria.- Specified by:
similaritySearchin interfaceVectorStore- 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:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-