Spring AI Tutorial: Configure Redis Vector Store & Build RAG with Advisors

This guide walks through configuring a Redis vector database with Spring AI, adding the vector store advisor for retrieval-augmented generation, ingesting documents via ETL pipelines, and testing the RAG flow with a sample conversation.

Java Captain
Java Captain
Java Captain
Spring AI Tutorial: Configure Redis Vector Store & Build RAG with Advisors

Configure Redis Vector Database

Add the Spring AI Redis vector store starter dependency to your project:

<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-starter-vector-store-redis</artifactId>
</dependency>

Then configure Redis connection properties (host, port, password, index name, etc.) as shown in the accompanying screenshot.

Redis vector store configuration properties
Redis vector store configuration properties

Enable RAG with Vector Store Advisor

To implement retrieval-augmented generation, include the vector store advisor dependency:

<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-advisors-vector-store</artifactId>
</dependency>

Create a QuestionAnswerAdvisor using the builder pattern because the class is package-private in Spring AI 1.1.2 and cannot be instantiated directly:

QuestionAnswerAdvisor builder configuration
QuestionAnswerAdvisor builder configuration

The Spring AI starter auto-configures a VectorStore bean at startup; inject it directly into your components.

During runtime the author encountered an EmbeddingModel unavailable error and resolved it by manually defining an embedding model bean:

Manual EmbeddingModel bean configuration
Manual EmbeddingModel bean configuration

Ingest Documents via ETL Pipeline

Spring AI provides ETL interfaces; use a Reader to convert files into Document objects and write them to the vector store:

Document ingestion code using Spring AI ETL Reader
Document ingestion code using Spring AI ETL Reader

Test the RAG Conversation

Run a sample chat; the advisor retrieves relevant context from Redis and augments the prompt. The screenshot shows the input text and the model's answer:

Sample RAG conversation input and output
Sample RAG conversation input and output

Verify Stored Vectors in Redis

Inspect the Redis index to confirm documents and embeddings were persisted correctly:

Redis vector index data view
Redis vector index data view
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

RAGRedisvector databaseSpring BootSpring AIETL Pipelineembedding modelQuestionAnswerAdvisor
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.