# Spring AI Modular RAG and TypeSafe Jev: Retrieve More, Keep Only What Answers

DevFeed: [Spring AI Modular RAG and TypeSafe Jev: Retrieve More, Keep Only What Answers](<https://devfeed.tech/articles/spring-ai-modular-rag-and-typesafe-jev-retrieve-more-keep-only-what-answers-63834.md>)

Original publisher: [Read original article](<https://spring.io/blog/2026/10/02/spring-ai-modular-rag-typesafe-jev>)

Author: tzolov

Published: 2026-10-02T00:00:00Z

Content type: article

Language: en

Sources: [Spring](<https://devfeed.tech/sources/spring.md>)

Topics: [Retrieval Augmented Generation (RAG)](<https://devfeed.tech/topics/retrieval-augmented-generation-rag.md>), [Spring AI](<https://devfeed.tech/topics/spring-ai.md>), [AI Architecture](<https://devfeed.tech/topics/ai-architecture.md>), [AI Integration Strategies](<https://devfeed.tech/topics/ai-integration-strategies.md>)

Tags: [batch](<https://devfeed.tech/tags/batch.md>), [boot](<https://devfeed.tech/tags/boot.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [event-driven](<https://devfeed.tech/tags/event-driven.md>), [java](<https://devfeed.tech/tags/java.md>), [jev](<https://devfeed.tech/tags/jev.md>), [llm](<https://devfeed.tech/tags/llm.md>), [microservices](<https://devfeed.tech/tags/microservices.md>), [modular](<https://devfeed.tech/tags/modular.md>), [naive-rag](<https://devfeed.tech/tags/naive-rag.md>), [pdf](<https://devfeed.tech/tags/pdf.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [rag](<https://devfeed.tech/tags/rag.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [retrieval](<https://devfeed.tech/tags/retrieval.md>), [serverless](<https://devfeed.tech/tags/serverless.md>), [spring](<https://devfeed.tech/tags/spring.md>), [spring-ai](<https://devfeed.tech/tags/spring-ai.md>), [typesafe](<https://devfeed.tech/tags/typesafe.md>), [web-applications](<https://devfeed.tech/tags/web-applications.md>)

## AI overview

The example combines Spring AI's Modular RAG pipeline with Jev to turn a chatty question into focused searches and keep retrieved passages that can answer it. `RetrievalAugmentationAdvisor` rewrites and expands the query, retrieves and deduplicates similar chunks, then applies `JevDocumentFilter` before `JevDocumentReranker`; the original question remains the input to post-processing and answer generation. In the Hurricane Milton demo, six retrieved chunks included reference entries that were topically similar but unhelpful. Jev filtered those out and kept two answer-bearing chunks, producing a response that Milton made landfall near Siesta Key on October 9, 2024, as a Category 3 hurricane. The filter preserves contradictory evidence, and both Jev stages fail open if the API is unreachable. The pipeline adds two LLM calls before retrieval and one Jev call per retrieved chunk, so the article advises measuring latency. It also notes that supplying Spring's `TaskExecutor` prevents a command-line app from hanging after output.

## Source excerpt

Spring AI: RAG Doc | Jev Doc | Demo In the previous article we introduced Spring AI TypeSafe and its Jev model: typed questions in, calibrated numbers out, in a few hundred milliseconds. One row in that article's SPI table deserves its own post. JevDocumentFilter and JevDocumentReranker are DocumentPostProcessors, which means they plug straight into Spring AI's Modular RAG pipeline. This article puts the two together. Two LLM calls clean up and multiply the user's question before retrieval. Jev then judges every retrieved chunk before it reaches the prompt. The whole pipeline is one advisor builder. 💡 Demo: The complete example is the 05-1-modular-rag module. It sits next to 05-rag, the naive version, so you can diff the two. Every output quoted below is from a live run. Why Naive RAG Falls Short The classic Spring AI RAG demo is a QuestionAnswerAdvisor over a vector store. It embeds the user's text, fetches similar chunks and stuffs them into the prompt. That works on stage and gets shaky in real life, for three reasons: Users don't type search queries. They type "I'm a Florida resident and heard a lot about storms last fall. Did Milton actually make landfall in my state, and where?" Embedding that verbatim drags all the noise into the search. Similar is not the same as useful. A vector store returns chunks that are about the topic. A reference list that mentions "Hurricane Milton" five times scores high and answers nothing. Retrieved text is untrusted input. Whatever sits in your documents goes straight into the prompt, including text written to hijack the model. We will answer exactly that question over a Wikipedia PDF about Hurricane Milton, and fix each problem with one pluggable component. Modular RAG in Spring AI The RetrievalAugmentationAdvisor, from the spring-ai-rag module, implements the architecture described in Modular RAG: Transforming RAG Systems into LEGO-like Reconfigurable Frameworks. From the outside it is just another advisor: it sits between you