Package com.redis.vl.langchain4j
Class RedisVLDocumentStore
java.lang.Object
com.redis.vl.langchain4j.RedisVLDocumentStore
RedisVL Document Store for storing raw binary content (images, PDFs, etc.) for multimodal RAG.
This store enables persistent storage of raw documents with metadata, separate from vector embeddings. Useful for multimodal RAG where text summaries are embedded for search, but raw images/content is needed for vision LLM generation.
Documents are stored as Redis Hashes with:
- content: Base64-encoded binary content
- metadata_*: Individual metadata fields
Example usage:
// Create document store
UnifiedJedis jedis = RedisClient.create("localhost", 6379);
RedisVLDocumentStore store = new RedisVLDocumentStore(jedis, "docs:");
// Store a document
byte[] imageBytes = Files.readAllBytes(Path.of("image.jpg"));
Map<String, String> metadata = Map.of("type", "image", "source", "page1.pdf");
store.store("doc_id_1", imageBytes, metadata);
// Retrieve document
Optional<Document> doc = store.retrieve("doc_id_1");
if (doc.isPresent()) {
byte[] content = doc.get().content();
Map<String, String> meta = doc.get().metadata();
// Use with vision LLM
}
// Builder pattern
RedisVLDocumentStore store = RedisVLDocumentStore.builder()
.jedis(jedis)
.keyPrefix("docs:")
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for RedisVLDocumentStore.static final recordRepresents a document with content and metadata. -
Constructor Summary
ConstructorsConstructorDescriptionRedisVLDocumentStore(UnifiedJedis jedis) Creates a new RedisVLDocumentStore with default prefix.RedisVLDocumentStore(UnifiedJedis jedis, String keyPrefix) Creates a new RedisVLDocumentStore with custom prefix. -
Method Summary
Modifier and TypeMethodDescriptionstatic RedisVLDocumentStore.Builderbuilder()Creates a builder for RedisVLDocumentStore.booleanDeletes a document by ID.getJedis()Gets the underlying Jedis client.Gets the key prefix.Lists all document IDs in this store.Retrieves a document by ID.voidStores a document with metadata.
-
Constructor Details
-
RedisVLDocumentStore
Creates a new RedisVLDocumentStore with default prefix.- Parameters:
jedis- The Redis client
-
RedisVLDocumentStore
Creates a new RedisVLDocumentStore with custom prefix.- Parameters:
jedis- The Redis clientkeyPrefix- The key prefix for Redis keys
-
-
Method Details
-
store
Stores a document with metadata.- Parameters:
id- Unique document identifiercontent- Binary contentmetadata- Optional metadata (can be null)- Throws:
IllegalArgumentException- if id or content is null
-
retrieve
Retrieves a document by ID.- Parameters:
id- Document identifier- Returns:
- Optional containing the document if found
-
delete
Deletes a document by ID.- Parameters:
id- Document identifier- Returns:
- true if document was deleted, false if it didn't exist
-
listDocumentIds
Lists all document IDs in this store.- Returns:
- List of document IDs
-
getJedis
Gets the underlying Jedis client.- Returns:
- The Redis client
-
getKeyPrefix
Gets the key prefix.- Returns:
- The key prefix
-
builder
Creates a builder for RedisVLDocumentStore.- Returns:
- A new builder instance
-